【问题标题】:matlab multiple x axis one below anothermatlab多个x轴一个在另一个下面
【发布时间】:2012-07-17 22:30:41
【问题描述】:

我正在尝试创建一个 matlab 绘图,其中有多个 x 轴一个在另一个之下,一个 y 轴。

我查看了 Mathworks 文件交换,只有多个 y 轴的建议/脚本。我想实现类似this question for R

【问题讨论】:

标签: matlab axis


【解决方案1】:

如果您只需要第二个轴来显示不同的比例,这是一个示例解决方案(Jeff_K 的解决方案,但更有效):

first_axis = gca;
sqz = 0.12; %// distance to squeeze the first plot
set(first_axis, 'Position', get(first_axis, 'Position') + [0 sqz 0 -sqz ]);
ax2 = axes('Position', get(first_axis, 'Position') .* [1 1 1 0.001] - [0 sqz 0 0],'Color','none');
scale_factor = 42; %// change this to your satisfaction
xlim(get(first_axis, 'XLim') * scale_factor);
set(ax2, 'XScale', get(first_axis, 'XScale')); %// make logarithmic if first axis is too

【讨论】:

    【解决方案2】:

    如果您实际上不需要在辅助轴上绘制数据,而只是使用它们来显示比例(如您链接到的示例),您可以通过添加第二个(或第三个等)来完成。 ) 轴在适当的位置,并将高度设置得很小:

    ax2 = axes('Position',[0.1 0.1 0.8 0.001],'Color','none')
    

    然后适当地设置刻度标签。

    【讨论】:

      【解决方案3】:

      您需要为此使用补丁功能。 更多详情请看这里:http://www.mathworks.com/matlabcentral/fileexchange/26550-myplotyy

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-09
        • 2014-03-23
        • 2018-06-17
        • 1970-01-01
        相关资源
        最近更新 更多