单个冲浪地块的多个轴

时间:2016-03-16 13:47:28

标签: matlab plot axes

我有一个冲浪地块,我希望有两个y轴。我似乎无法找到任何其他类似的讨论。

我到目前为止最接近的是:

surf(peaks);
view(0,0)
ax(1) = gca;
axPos = ax(1).Position;
ax(2) = axes('Position',axPos, 'Color', 'none','XTick',[],'ZTick',[],'YAxisLocation','right');
linkprop(ax, 'CameraPosition');
rotate3d on

1 个答案:

答案 0 :(得分:1)

% Desired plot
surf(peaks);

% Save axis
ax(1) = gca;

% Use the position of the first axis to define the new axis
pos = ax(1).Position;
pos2 = pos - [0.08 0 0 0];
ax(2) = axes('Position',pos2,'Color', 'none');

% Plot random line in 3D, just make sure your desired axis is correct
plot3(ones(length(peaks),1), 10:10:length(peaks)*10,...
    ones(length(peaks),1), 'Color','none')

% Make plot, and non-desired axes, invisible
set(gca,'zcolor','none','xcolor','none','Color','none')

% Link axes
linkprop(ax, 'View');