How to show legends for dotted lines in Bar chart figure

조회 수: 6 (최근 30일)
Sumit Saha
Sumit Saha 2021년 5월 30일
댓글: Sumit Saha 2021년 5월 31일
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
Walter Roberson
Walter Roberson 2021년 5월 30일
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 2021년 5월 31일
@Walter Roberson okay...then I'm using textbox. Thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by