How do I overlap image with a graph in MATLAB?
I want to write a software that reads the satellite data from a text file and plots graph for different parameters of the o开发者_开发百科ceans. The idea came from Oceonographic Data View(ODV).
My problem is plotting a graph on an image of the Indian ocean, where the image must be overlapped with the graph. Also, on zooming the area, the image with the graph could be zoomed.
How can I do this?
To load and display images, the Displaying Bit-Mapped Images tutorial from MathWorks may not be a bad place to start.
To overlay plots on the image, using hold on
followed by plot
should work.
An important part will be to have a sensible metric when displaying your image that allows you to place your overlays accurately. In the example below, notice the first and second arguments to image
that define this; you could replace it by say linspace(0,1,size(X,1))
if you wanted it scaled between 0 and 1 instead of between 1 and 480 as below.
load mandrill
image(1:480,1:500,X) % display image
colormap(map)
hold on % prevent subsequent plot commands from destroying the image
plot([1 480],[100 100],'w','LineWidth',2) % plot an overlay line
精彩评论