how can I plot a graph over an image in Matlab?
16 views (last 30 days)
Kevin Holly on 30 Jun 2022
Load Example Image
exampleimage = imread('peppers.png');
Flip the image vertically (y-axis direction will be flipped vertically later)
exampleimage = flipud(exampleimage);
Use hold on so more children can be added to the axes
Create scatter plot
Change y-dir to normal (Note, y-dir is upside down when images are displayed by default)
set(gca,'YDir','normal') %gca stand for get current axes
More Answers (2)
Adam Danz on 30 Jun 2022
Plot the image using image or imagesc or some other image function that allows you to specify the x and y values of the image. That way you set the image coordinates to the data coordinates.
Then just hold on and plot the data into the same axes.
Note that image functions flip the y axis so you may need to flip it back to normal using set(gca, 'YDir','Normal') or flip your data when you plot it.
If you have additional questions, share the code you've got so far and let us know specificially where you're stuck.