overlay plot on top of image in uiaxes (gui)

10,458

plot indeed accept a parent handle, check out this help page:

plot(handles.pictureBox,[p.centers.x], [p.centers.y], 'r.');

Furthermore, hold also accept axes handle. You can use the following:

hold(handles.pictureBox,'on');

(or 'off' obviously...)

Share:
10,458
Dr.YSG
Author by

Dr.YSG

PhD (CS) working in a broad area of technologies: Big Data GPU computing & Non-Von-Neumann programming Cloud Computing Massive distributed gaming (scientific simulations) Computer Vision, Robotics Augmented Reality Mobile GIS 2D/3D Simulation & Virtual Reality serious games 3D Graphics HTML5 for offline mobile apps Data & Info Visualization MultiMedia Real-time collaboration (mobile tech) User Interfaces (video and NUI) as well as Human Centered Design NodeJS,Express, OGMA, Neo4j Graph Database React, Redux, Redux-Thunk, Redux-Form, Electron, the Redux Ecosystem

Updated on June 04, 2022

Comments

  • Dr.YSG
    Dr.YSG almost 2 years

    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.

    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.