buysnow 2023-03-15 16:35 采纳率: 68.8%
浏览 149
已结题

matlab,想让三个子图的大小一样,怎么样设置

matlab画图,我想让三个子图的大小一样,怎么样设置

img


```figure
subplot(3,1,1)
plot(ds,'b','LineWidth',1)
hold on;
plot([a,a],'r--','LineWidth',1.5)
hold on
plot([b,b], 'g--','LineWidth',1.5)
hold on
plot([c,c],'m--','LineWidth',1.5)
hold on
plot([d,d],'c--','LineWidth',1.5)
hold on
plot([e,e], 'k--','LineWidth',1.5)
str1='\fontsize{12}\fontname{宋体}采样点';
xlabel(str1)

lgd = legend('标签1','标签2','标签3','标签4','标签5','标签6','Location','NorthOutside')  % 注意这一行的句尾不加分号;可以显示legend的参数
lgd.NumColumns = 3;
lgd.Location='northoutside';

subplot(312)
plot(ds1,'b','LineWidth',1)
hold on;
plot([a,a],'r--','LineWidth',1.5)
hold on
plot([b,b], 'g--','LineWidth',1.5)
hold on
plot([c,c],'m--','LineWidth',1.5)
hold on
plot([d,d],'c--','LineWidth',1.5)
hold on
plot([e,e], 'k--','LineWidth',1.5)
str1='\fontsize{12}\fontname{宋体}采样点';
xlabel(str1)

subplot(313)
plot(ds2,'b','LineWidth',1)
hold on;
plot([a,a],'r--','LineWidth',1.5)
hold on
plot([b,b], 'g--','LineWidth',1.5)
hold on
plot([c,c],'m--','LineWidth',1.5)
hold on
plot([d,d],'c--','LineWidth',1.5)
hold on
plot([e,e], 'k--','LineWidth',1.5)
str1='\fontsize{12}\fontname{宋体}采样点';
xlabel(str1)


```

  • 写回答

2条回答 默认 最新

  • MarkHan_ 2023-03-15 17:17
    关注

    该回答引用GPTᴼᴾᴱᴺᴬᴵ
    您可以在创建figure对象之后,设置子图的高度和宽度比例,以保证三个子图的大小一致。以下是一个示例代码:

    fig = figure;
    set(fig, 'Units', 'normalized', 'Position', [0.1, 0.1, 0.8, 0.8]); % 设置整个figure的位置和大小
    ax1 = subplot(3,1,1);
    plot(ds,'b','LineWidth',1)
    %...subplot(1)的绘图代码
    ax2 = subplot(3,1,2);
    plot(ds1,'b','LineWidth',1)
    %...subplot(2)的绘图代码
    ax3 = subplot(3,1,3);
    plot(ds2,'b','LineWidth',1)
    %...subplot(3)的绘图代码
    set(ax1,'Position',[0.1 0.67 0.8 0.25]); % 设置第一个子图的位置和大小
    set(ax2,'Position',[0.1 0.39 0.8 0.25]); % 设置第二个子图的位置和大小
    set(ax3,'Position',[0.1 0.11 0.8 0.25]); % 设置第三个子图的位置和大小
    
    
    

    在上述代码中,set函数用于设置子图的属性。其中,'Position'属性设置子图的位置和大小。[0.1 0.67 0.8 0.25]表示子图的左下角坐标为(0.1, 0.67),宽度占整个figure的80%,高度为整个figure的25%。[0.1 0.39 0.8 0.25]和[0.1 0.11 0.8 0.25]分别表示第二个和第三个子图的位置和大小。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月23日
  • 已采纳回答 3月15日
  • 修改了问题 3月15日
  • 修改了问题 3月15日
  • 展开全部

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳