在Matlab中绘制外轴

ths*_*104 5 graphics matlab figure

如何用MATLAB绘制轴外的东西?我想画一些类似于这个数字的东西;

在外轴上绘制条形图

谢谢.

Amr*_*mro 6

通过使用两个轴,这是一个可能的技巧:

%# 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')
Run Code Online (Sandbox Code Playgroud)

这是前后的情节:

before_screenshot after_screenshot