Insert Background Image Behind Subplots
12 次查看(过去 30 天)
显示 更早的评论
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)))
0 个评论
采纳的回答
Geoff Hayes
2020-3-30
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!