【问题标题】:Plotting two Matlab figures next to each other绘制两个相邻的 Matlab 图形
【发布时间】:2016-01-13 15:35:20
【问题描述】:

我正在尝试将这两个数字并排绘制。这个想法是在 x 轴上创建 1 到 10 的正方形图。我知道 subplot 功能,但有些它对我不起作用。非常感谢您的帮助。

   % plotting the data
data1_plot=data1.*100; 
data2_plot=data2.*100; 
figure(1),
subplot(1,2,1); 
plot((1:10)',mean(data1_plot),'o-','LineWidth',1);hold on
for ii=2:10;
    if mean(data1_plot(:,ii))<mean(data1_plot(:,ii-1));
        plot([ii-1,ii],mean(data1_plot(:,ii-1:ii)),'r.-');
    end
end
set(gca,'XTickLabel',{'Unprofitable';'2';'3';'4';'5';'6';'7';'8';'9';'Profitable'});
axis([0.8,10.2,0.0,1.5]),...
    ylabel('Average return'),...
    title('\rm Equally-weighted PMU portfolio returns, 1990-2015');hold off;
subplot(1,2,2); 
plot((1:10)',mean(data2_plot),'o-','LineWidth',1);hold on
for ii=2:10;
    if mean(data2_plot(:,ii))<mean(data2_plot(:,ii-1));
        plot([ii-1,ii],mean(data2_plot(:,ii-1:ii)),'r.-');
    end
end
set(gca,'XTickLabel',{'Weak';'2';'3';'4';'5';'6';'7';'8';'9';'Robust'});
axis([0.8,10.2,0.0,1.5]),...
    ylabel('Average return'),...
    title('\rm Equally-weighted RMW returns, 1990-2015');hold off;

plots

【问题讨论】:

  • 您的情节链接看起来不错(除了格式不正确)您希望情节看起来像什么?你的描述很模糊。
  • 绘图链接是输出。问题是,当我将下摆绘制成两个独立的图形时,我会得到两个非常整齐的正方形图形。但是,当我将绘图与 subplot 函数结合起来时,我会得到链接中给出的输出。我希望在不调整大小的情况下合并这两个地块

标签: matlab figure subplot


【解决方案1】:

你可以使用

axis square
xlim([1 10])

第一个命令使当前坐标区区域为正方形 (web),第二个命令设置 x 轴限制。

例子:

subplot(1,2,1)
plot(1:10);
axis square
xlim([0 12]);

subplot(1,2,2)
plot(1:10);
axis square
xlim([1 10]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-05
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 2019-03-10
    • 1970-01-01
    相关资源
    最近更新 更多