在matlab中关闭轴可见性

时间:2013-12-02 05:17:35

标签: matlab

我正在尝试绘制一个散点图,其中图像作为一个子图中的背景。我希望所有轴在这个特定的子图上都不可见。但是,这似乎不起作用:

subplot('Position',[0.4, 0.58, 0.5, 0.46])
ha = axes('units','normalized','position',[0.4, 0.58, 0.5, 0.46]);
I=imread('myimage.tif');
image(I)
set(ha,'Visible','off')
hb = axes('position',[0.4, 0.58, 0.5, 0.46]);
scatter(x,y,10,'k')
set(hb,'Visible','off')

2 个答案:

答案 0 :(得分:2)

你差不多完成了,用这种方式修改你的代码:

h_subplot = subplot('Position',[0.4, 0.58, 0.5, 0.46]);
axis off
ha = axes('units','normalized','position',[0.4, 0.58, 0.5, 0.46]);
I=imread('ngc6543a.jpg'); % your image
image(I)
axis off
hb = axes('position',[0.4, 0.58, 0.5, 0.46]);
x = cumsum(randn(1e3, 1)); % your x
y = cumsum(randn(1e3, 1)); % your y
h_scatter = scatter(x, y, 50, 'w', 'Marker', 'o', 'MarkerFaceColor', 'w');
axis off

答案 1 :(得分:0)

如果我理解正确,您只需要以下内容:

%Display first image:
I=imread('myimage.tif');
image(I);

%Turn axis off
axis off;

%Display scatter plot
scatter(x,y,10,'k');

根据需要调整缩放和/或定位。