Oh yes, It is very important that the scale of the axis be maintained between the image and the plot. Right now, I see the plot adjusting the x,y bounds. If the imshow is a image of 1K x 1K, then I want the plot range to be exactly the same so that the labels overlay.
Plotting points on top of image (imshow) (uiaxes)
42 views (last 30 days)
Show older comments
I had the following code (which works) that does an imshow raster data and then plots red dots on top of a list of markers (I.e. the base layer is an image of stars, and the overlay is red dots that mark them).
function plot(this)
imshow(WORLD.image, [0 1]);
hold on
plot([this.centers.x], [this.centers.y], 'r.');
hold off
end
OK, now I am using GUIDE to create the GUI, and I have the imshow using the parent property to get the image inside of a ui-axes. That part works, but the plot does not seem to take Parent, and besides hold on and hold off does not work (it creates a new window with the plot). How do I fix this? [handles.pictureBox is the handle for the axes control]
imshow(WORLD.mask, [0 1], 'Parent', handles.pictureBox);
hold on
plot([p.centers.x], [p.centers.y], 'r.', 'Parent', handles.pictureBox);
hold off
What I observe is that if I remove the hold on, hold off, then the base image is replaced by the plot. But if I leave it in, the same thing happens, but a pop-up also shown.
Answers (1)
Daksh
on 31 Jan 2023
I understand that you're experiencing issues with plotting points on top of image while using GUIDE and using "hold on" and "hold off" as "plot()" method seems to be not taking the parent handle for your case.
As per the R2022b documentation for MATLAB, "plot" method indeed accepts a parent handle, kindly refer to this link:
plot(handles.pictureBox,[p.centers.x], [p.centers.y], 'r.');
Furthermore, "hold" ("on" and "off" both) also accepts axes handle, kindly use them as follows:
hold(handles.pictureBox,'on');
Hope this helps!
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!