Filter löschen
Filter löschen

How to show legends for dotted lines in Bar chart figure

2 Ansichten (letzte 30 Tage)
Sumit Saha
Sumit Saha am 30 Mai 2021
Kommentiert: Sumit Saha am 31 Mai 2021
I'm trying to show legends for the dotted st lines but they're getting merged with the bar legends
clear all
close all
clc
%% Median & Dispersion for Different storey SMRF
figure(1)
subplot(2,2,1)
median_UL_0 = [1,4,6;5 6 9;8 9 23];
Rupture_distance = [ 5 10 15];
hb = bar(Rupture_distance,median_UL_0);
hold on
hx = xlabel('R_r_u_p (km) ', 'Fontsize', 12);
hy = ylabel(' Fragility Parameter (Median) ', 'Fontsize', 12);
title(' Directivity Case : UL0') %' Parametric variation for different storey buildings:
ylim([0 2])
xlim([0 20])
plot(xlim,[1 1]*1.49, '--k','linewidth',2.5)
hold on
plot(xlim,[1 1]*1.43, '--b','linewidth',2.5)
hold on
plot(xlim,[1 1]*1.31, '--r','linewidth',2.5)
legend('Hazus Limit for S1L','Hazus Limit for S1M','Hazus Limit for S1H')
yticks([0.0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2.0])
set(gcf,'position',[ 140 370 850 770])
% set(findall(gcf,'-property','Fontsize'),'Fontsize',12)
%hb(1).FaceColor = 'b';
%hb(2).FaceColor = 'y';
%hb(3).FaceColor = 'r';
hold on
% add legend
legh = legend('1 storey SMRF','5 storey SMRF','9 storey SMRF','Location','northoutside','Orientation','horizontal');
set(legh, 'fontsize', 10)
Lgnd = legend('show');
Lgnd.Position(1) = 0.335;
Lgnd.Position(2) = 0.965;
print('DT2100','-dpng','-r300');
%
subplot(2,2,2)
median_UL4 = [10,14,15;18,21,23;20,12,14];
Rupture_distance = [ 5 10 15];
bar(Rupture_distance,median_UL4)
hold on
hx = xlabel('R_r_u_p (km) ', 'Fontsize', 10);
hy = ylabel(' Fragility Parameter (Median) ', 'Fontsize', 10);
title(' Directivity Case : UL4') %' Parametric variation for different storey buildings:
hold on
ylim([0 2])
xlim([0 20])
plot(xlim,[1 1]*1.49, '--k','linewidth',2.5)
hold on
plot(xlim,[1 1]*1.43, '--b','linewidth',2.5)
hold on
plot(xlim,[1 1]*1.31, '--r','linewidth',2.5)
legend('Hazus Limit for S1L','Hazus Limit for S1M','Hazus Limit for S1H')
%yticks([0.0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2.0])
set(gcf,'position',[ 140 370 850 770])
%hb(1).FaceColor = 'b';
%hb(2).FaceColor = 'y';
%hb(3).FaceColor = 'r';
set(gcf,'position',[ 140 370 850 770])
% set(findall(gcf,'-property','Fontsize'),'Fontsize',12)
hold on
print('DT2100','-dpng','-r300');
  7 Kommentare
Walter Roberson
Walter Roberson am 30 Mai 2021
legend('Hazus Limit for S1L','Hazus Limit for S1M','Hazus Limit for S1H')
legh = legend('1 storey SMRF','5 storey SMRF','9 storey SMRF','Location','northoutside','Orientation','horizontal');
You cannot have two different legend boxes for the same axes.
Sumit Saha
Sumit Saha am 31 Mai 2021
@Walter Roberson okay...then I'm using textbox. Thanks

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by