码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab Plot 使用多个图例( legend )

时间:2014-07-12 21:03:59      阅读:2602      评论:0      收藏:0      [点我收藏+]

标签:matlab

     用matlab 画图时,发现线太多,生成的图例,遮盖了曲线。于是想画成多个图例,然后可以自由拖动。

     废话不多说,1)代码; 2)效果。


%%%%%%%%%%%%  Code:

figure
%% ---- plot for maxtries performance
set(0,'DefaultTextFontName','Times',...
    'DefaultTextFontSize',16,...
    'DefaultAxesFontName','Times',...
    'DefaultAxesFontSize',12,...
    'DefaultLineLineWidth',1,...
    'DefaultLineMarkerSize',6);
% set(gcf,'Units','inches','Position',[0 0 6.0 4.0]);

% ======================= trace_1:
% --- 1 UB_ratio_EMF_10_A_trace_1
h10_1_tr1=plot(X_items, UB_ratio_EMF_10_A_trace_1, '-pk');
hold on
% --- 2 Real Ratio
h10_2_tr1=plot(X_items, Ratio_EMF_10_over_OPT_trace_1, '-.or');
hold on
h10_3_tr1=plot(X_items, LB_ratio_EMF_10_A_trace_1, '-^b');
hold on
% ======================= trace_1:~

% ======================= trace_2:
% --- 1 UB_ratio_EMF_10_A_trace_2
h10_1_tr2=plot(X_items, UB_ratio_EMF_10_A_trace_2, '-+k');
hold on
% --- 2 Real Ratio
h10_2_tr2=plot(X_items, Ratio_EMF_10_over_OPT_trace_2, '-.dr');
hold on
h10_3_tr2=plot(X_items, LB_ratio_EMF_10_A_trace_2, '->b');
hold on
% ======================= trace_2:~

% ======================= trace_3:
% --- 1 UB_ratio_EMF_10_A_trace_3
h10_1_tr3=plot(X_items, UB_ratio_EMF_10_A_trace_3, '-xk');
hold on
% --- 2 Real Ratio
h10_2_tr3=plot(X_items, Ratio_EMF_10_over_OPT_trace_3, '-.sr');
hold on
h10_3_tr3=plot(X_items, LB_ratio_EMF_10_A_trace_3, '-<b');
hold on
% ======================= trace_3:~
grid
ylim([0.5 2.5])
xlabel('Length of time-slot (seconds)')
ylabel('Ratio')
legend('U.B. ratio,\beta=10,Trace 1','Real ratio,\beta=10,Trace 1','L.B. ratio,\beta=10,Trace 1',0)
ah1_f10=axes('position',get(gca,'position'),...
            'visible','off');
legend(ah1_f10,[h10_1_tr2 h10_2_tr2 h10_3_tr2],'U.B. ratio,\beta=10,Trace 2','Real ratio,\beta=10,Trace 2','L.B. ratio,\beta=10,Trace 2',  ...
               'location','west', 0)
ah2_f10=axes('position',get(gca,'position'),...
            'visible','off');
legend(ah2_f10,[h10_1_tr3 h10_2_tr3 h10_3_tr3],'U.B. ratio,\beta=10,Trace 3','Real ratio,\beta=10,Trace 3','L.B. ratio,\beta=10,Trace 3',  ...
               'location','west', 0)


%  效果:

bubuko.com,布布扣

bubuko.com,布布扣


Davy_H

2014-7-10

Matlab Plot 使用多个图例( legend ),布布扣,bubuko.com

Matlab Plot 使用多个图例( legend )

标签:matlab

原文地址:http://blog.csdn.net/davyhwang/article/details/37660073

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!