Matlab两个子图共用一个图例(legend函数)

y1 = rand(10,2);
y2 = repmat(1:10,2,1)';
y2(:,2) = y2(:,1) + 1 ;
subplot(1,2,1,'position',[0.13  0.2 0.34  0.75]);
h{1} = plot(y1);
yticks([0 0.5 1])
xticks([0 5 10])
 set(gca,'FontName','Times New Roman','FontSize',14);
subplot(1,2,2,'position',[0.57  0.2 0.34 0.75]);
h{2} = plot(y2);
yticks([0 3 9 11])
xticks([0 5 10])
set(gca,'FontName','Times New Roman','FontSize',14);
hh = legend([h{1};h{2}],'y1','y2','Orientation','horizontal', 'location',[0.13,0.05,0.74,0.05],'FontName','Times New Roman','FontSize',14);

在这里插入图片描述

最近更新

  1. TCP协议是安全的吗?

    2023-12-15 07:14:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-15 07:14:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-15 07:14:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-15 07:14:01       18 阅读

热门阅读

  1. [Android] Binder all-in-all

    2023-12-15 07:14:01       41 阅读
  2. Android RecycleView实现平滑滚动置顶和调整滚动速度

    2023-12-15 07:14:01       37 阅读
  3. android 9 Systemui 动态隐藏导航栏

    2023-12-15 07:14:01       33 阅读
  4. 前端已死?未来的出路?

    2023-12-15 07:14:01       35 阅读
  5. 用python写一段收到邮件会在桌面弹出提醒

    2023-12-15 07:14:01       32 阅读
  6. android从ftp,阿里云,腾讯云下载zip

    2023-12-15 07:14:01       45 阅读
  7. 单元测试二(理论)-云计算2023.12-云南农业大学

    2023-12-15 07:14:01       28 阅读