如何使用MATLAB在轴外绘制图形?我想画些类似于这个数字的东西。
谢谢你。
最佳答案
这是使用两个轴的一种可能的技巧:
%# plot data as usual
x = randn(1000,1);
[count bin] = hist(x,50);
figure, bar(bin,count,'hist')
hAx1 = gca;
%# create a second axis as copy of first (without its content),
%# reduce its size, and set limits accordingly
hAx2 = copyobj(hAx1,gcf);
set(hAx2, 'Position',get(hAx1,'Position').*[1 1 1 0.9], ...
'XLimMode','manual', 'YLimMode','manual', ...
'YLim',get(hAx1,'YLim').*[1 0.9])
delete(get(hAx2,'Children'))
%# hide first axis, and adjust Z-order
axis(hAx1,'off')
uistack(hAx1,'top')
%# add title and labels
title(hAx2,'Title')
xlabel(hAx2, 'Frequency'), ylabel(hAx2, 'Mag')
这是之前和之后的情节:
关于matlab - 在Matlab中绘制外轴,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6964450/