关于matlab的图例
plot(t1,U1_A,'-r','linewidth',1.0);holdon;plot(t2,U1_S,'o','markerfacecolor','w','lin...
plot(t1,U1_A,'-r','linewidth',1.0);
hold on;
plot(t2,U1_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
plot(t1,U6_A,'-r','linewidth',1.0);
hold on;
plot(t2,U6_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
plot(t1,U10_A,'-r','linewidth',1.0);
hold on;
plot(t2,U10_S,'o','markerfacecolor','w','linewidth',0.5);
legend('解析解','模拟值');
legend('boxoff');legend(gca,'Orientation','horizontal');
legend boxoff;
上面是我的代码,我画了三条线,然后与这三线线相对应的点。这些线代表的是解析值,点代表是模拟值。我只想显示出一个图例,可是上面的代码会显示这六个数据系列的图例,如下图所示。请问该如何设置呀? 展开
hold on;
plot(t2,U1_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
plot(t1,U6_A,'-r','linewidth',1.0);
hold on;
plot(t2,U6_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
plot(t1,U10_A,'-r','linewidth',1.0);
hold on;
plot(t2,U10_S,'o','markerfacecolor','w','linewidth',0.5);
legend('解析解','模拟值');
legend('boxoff');legend(gca,'Orientation','horizontal');
legend boxoff;
上面是我的代码,我画了三条线,然后与这三线线相对应的点。这些线代表的是解析值,点代表是模拟值。我只想显示出一个图例,可是上面的代码会显示这六个数据系列的图例,如下图所示。请问该如何设置呀? 展开
2个回答
展开全部
% 把每个句柄记录下来,可以选择需要的线的句柄,进行legend
h1=plot(t1,U1_A,'-r','linewidth',1.0);
hold on;
h2=plot(t2,U1_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
h3=plot(t1,U6_A,'-r','linewidth',1.0);
hold on;
h4=plot(t2,U6_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
h5=plot(t1,U10_A,'-r','linewidth',1.0);
hold on;
h6=plot(t2,U10_S,'o','markerfacecolor','w','linewidth',0.5);
legend([h1,h2]',解析解','模拟值'); %需要显示哪个都可以
legend('boxoff');legend(gca,'Orientation','horizontal');
legend boxoff;
h1=plot(t1,U1_A,'-r','linewidth',1.0);
hold on;
h2=plot(t2,U1_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
h3=plot(t1,U6_A,'-r','linewidth',1.0);
hold on;
h4=plot(t2,U6_S,'o','markerfacecolor','w','linewidth',0.5);
hold on;
h5=plot(t1,U10_A,'-r','linewidth',1.0);
hold on;
h6=plot(t2,U10_S,'o','markerfacecolor','w','linewidth',0.5);
legend([h1,h2]',解析解','模拟值'); %需要显示哪个都可以
legend('boxoff');legend(gca,'Orientation','horizontal');
legend boxoff;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询