1

I am trying to plot a scatter plot with an image as the background in one subplot. I want all axes to be invisible on this particular subplot. However, this doesn't seem to be working:

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')
user2861089
  • 1,205
  • 4
  • 22
  • 44

2 Answers2

2

You are almost done, modify your code this way:

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
randomatlabuser
  • 626
  • 4
  • 13
0

If I understand correctly, all you need is the following:

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

%Turn axis off
axis off;

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

Make adjustments to the scaling and/or positioning as necessary.

Roney Michael
  • 3,964
  • 5
  • 30
  • 45