MATLAB: Adjust plot to image size

imageMATLAB and Simulink Student Suiteplotting

Hi Everyone,
I want to plot a graph over an image. the image is 750X800 but my graph goes from 0 to 20 on x axis and 0 to 36 on y axis. As a result the graph looks very small and shrinked up. How can I adjust the size of graph so it looks normal over the image.

Best Answer

If you use image() or imagesc() to draw the image, then you can specify leading parameters that are boundaries of where to place the image in data coordinates.
image(xlocation, ylocation, ImageArray)
If you use image() or imagesc() or imshow() then you can instead pass in 'XData' and 'YData' options to control the positions:
image(ImageArray, 'XData', xlocation, 'YData', ylocation)
The x location you pass in is a vector of values. The first value is used to control the x data coordinate at which the center of the bottom left pixel is to be placed. The last value is used to control the x data coordinate at which the center of the top right pixel is to be placed. Any other entries in the vector are ignored. Likewise, the y vector is used to control the y data coordinate of the center of bottom left, and center of top right.
I emphasize: coordinates of centers . So if you give a data coordinate of 0 then do not be surprised to see the last pixel sticking out past 0.