how to make an image over some background picture?

5 views (last 30 days)
I am gradually drawing an image on axes (creating the effect of image "slides in"), using
set(gca,'xlim',[0 120*fps],'ylim',[0 25],'nextplot','add','ydir','reverse');
Question is, the default background is a a simple white plane. How can I change it to my own picture?
I mean, if I place my picture on that axes, then the xlim and ylim becomes the size of the picture and I loose the settings I've made in an earlier command.

Accepted Answer

Mayank Dwivedi
Mayank Dwivedi on 9 Feb 2016
Hi Mark,
The link below describes how to add an image to the axis:
The answer mentioned in the link above plots an axis then uses a custom image as it's background. This axes is then made invisible and to plot again a new axes is used.
When you plot again, the new axis will also have a white background. To make the axis transparent and make the background picture visible you need to set the axis 'Color' property to 'None' after you have plotted the data. For example, after making the first axis invisible as described in the link above you do the following to plot the data with background image visible-
>> set(ha,'handlevisibility','off', ...
>> ha2 = axes('position',[0.3,0.35,0.4,0.4])
>> plot(rand(4))
>> set(gca, 'Color', 'None')
You can try implementing the "slide in" effect as you mentioned with the new axis. If you still face the issue please share the script that you are using.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!