Adjust plot to image size
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Gurbir Sandhu
il 5 Dic 2020
Commentato: Walter Roberson
il 6 Dic 2020
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.
0 Commenti
Risposta accettata
Walter Roberson
il 6 Dic 2020
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.
4 Commenti
Walter Roberson
il 6 Dic 2020
Notice the slight border shift, most noticeable at the bottom. If i recall correctly, the default for image() is to put the center of the bottom left pixel at (1,1)
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

