8

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

我查看了 Mathworks 文件交换,只有多个 y 轴的建议/脚本。我想为 R 实现类似这个问题的东西。

4

3 回答 3

4

如果您只需要第二个轴来显示不同的比例,这是一个示例解决方案(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
于 2014-09-05T15:25:57.493 回答
3

如果您实际上不需要在辅助轴上绘制数据,而只是使用它们来显示比例(如您链接到的示例),您只需在适当的位置,并将高度设置得非常小:

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

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

于 2013-08-14T06:39:20.273 回答
-1

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

于 2012-08-11T04:27:33.443 回答