Plotting points on top of image (imshow) (uiaxes)
Ältere Kommentare anzeigen
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.
Antworten (1)
Daksh
am 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!
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!