matlab - 在 Matlab 中绘制外轴

标签 matlab graphics figure

如何使用 MATLAB 在轴外绘制一些东西?我想绘制类似于此图的东西;

Plot with bar outside axis

谢谢。

最佳答案

这是使用两个轴的一种可能的技巧:

%# 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')

这是之前和之后的情节:

before_screenshot after_screenshot

关于matlab - 在 Matlab 中绘制外轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6964450/

相关文章:

Matlab - With ... 结束结构

matlab - 使用 matlab 从图像中选择随机补丁

matlab - 使用 HMM Matlab 进行序列预测

java - 针对大面积相同颜色优化的图像模糊

html - 将 div 包装在图形标签内?

arrays - 如何在图中显示带有文本框的数组?

matlab - 检测图像中的数独方 block

c++ - DirectX 9 固定功能纹理

基于 Java Tile 的光照性能问题

matplotlib - 如何在matplotlib中叠加数字