Borrar filtros
Borrar filtros

Insert Background Image Behind Subplots

12 visualizaciones (últimos 30 días)
Hannah Germaine
Hannah Germaine el 30 de Mzo. de 2020
Comentada: Hannah Germaine el 9 de Abr. de 2020
I'm looking for a way to plot an image behind a grid of subplots in MATLAB. I attempted to do so by plotting an image, and then plotting subplots but removing their backgrounds and axes. I have attached what the background image looks like and what the subplots in front look like.
Here is the stripped down code I used to attempt this setup. It results in only the subplot image file.
box = 20;
i = 10;
x_range = pw_responses(i).x_range; %x range for which to plot background image
y_range = pw_responses(i).y_range; %y range for which to plot background image
im = pref_mat(y_range,x_range); %this plotted image is in the background_im.png file
figure(i)
imagesc(im)
colormap(hsv)
set(gca,'XTick',[], 'YTick', [])
hold on
for j = 1:441 %the following subplots are in the subplots.png file
y_vals = surr_cell_resp(j,:); %response curve
subplot(box+1,box+1,j);
plot(x_vals,y_vals,'k')
set(gca,'visible','off')
set(gca,'XTick',[], 'YTick', [])
end
sgtitle(strcat('PW # = ',string(i)))

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 30 de Mzo. de 2020
Hannah - How do I add a background image to my GUI or figure window? provides a good answer on how to add a background image to your figure. In your case, I suspect that you could do something like
box = 20;
i = 10;
x_range = pw_responses(i).x_range; %x range for which to plot background image
y_range = pw_responses(i).y_range; %y range for which to plot background image
im = pref_mat(y_range,x_range); %this plotted image is in the background_im.png file
hFig = figure(i);
hAxes = axes('Parent', hFig, 'units', 'normalized', 'position',[0 0 1 1]);
imagesc(im);
colormap(hsv);
set(hAxes, 'HandleVisibility', 'off', 'Visible','off');
for j = 1:441 %the following subplots are in the subplots.png file
y_vals = surr_cell_resp(j,:); %response curve
hSubPlot = subplot(box+1,box+1,j);
plot(x_vals,y_vals,'k')
set(hSubPlot, 'HandleVisibility', 'off', 'Visible','off', 'Color', 'none');
end
  1 comentario
Hannah Germaine
Hannah Germaine el 9 de Abr. de 2020
Thank you Geoff, this worked perfectly! I simply modified the axes of the figure to:
hAxes = axes('Parent', hFig, 'units', 'normalized', 'position',[0.1300 0.1100 0.7750 0.8150]);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by