Plot position in uiaxes not precise?

4 visualizzazioni (ultimi 30 giorni)
Jonas
Jonas il 24 Apr 2023
Commentato: Jonas il 8 Mag 2023
Dear community,
- Edit below -
I tried to plot a cross on an image placed into a uiaxes in a uifigure and i noticed, that the cross is not exactly at my mouse location. Is this a graphics problem on my side or does it also appear for others? I tried two version, once with the Intersection Point of the Image Button Down Callback and once the CurrentPoint property of the uiaxes callback, both do not result into precise crosses:
here a MWE:
f=uifigure;
ax=uiaxes(f);
im=imagesc(ax,rand(5));
hold(ax,'on');
im.ButtonDownFcn=@(~,event) plot(ax,event.IntersectionPoint(1),event.IntersectionPoint(2),'Color','red','Marker','x','MarkerSize',12);
and here using the current point of the axes:
f=uifigure;
ax=uiaxes(f);
im=imagesc(ax,rand(5));
im.HitTest="off";
hold(ax,'on');
ax.ButtonDownFcn=@(src,~) plot(src,src.CurrentPoint(1,1),src.CurrentPoint(1,2),'Color','red','Marker','x','MarkerSize',12);
unfortunately i can not show a screenshot, since the mouse in not captured using the windows onboard screenshot tools. The plot location can vary in all directions.
EDIT:
I just noticed the reason for this behavior may be due to the attached monitor I use with my laptop or the display scaling. Does somone know some kind of workaround for the issue?
EDIT2:
My setting were 125% scaling on the laptop screen and 100% scaling on the additional monitor. using these settings, the plot location was precise on th elaptio screen, but not on the monitor. If I change the scaling of the monitor also to 125%, the positioning becomes precise.
EDIT3:
finally, this is all about scaling problems in matlab. see workaround in
actually, i dont know if there is also that problem for compiled apps
  2 Commenti
chicken vector
chicken vector il 24 Apr 2023
Just a quick comment since you have already figured it out.
This always work, regardless of the monitor settings:
f=uifigure;
ax=uiaxes(f);
im=imagesc(ax,rand(5));
hold(ax,'on');
im.ButtonDownFcn={@makeCross,ax};
function makeCross(~,event,ax)
point = get(ax,'CurrentPoint')
plot(ax,point(1,1),point(1,2),'Color','red','Marker','x','MarkerSize',12);
end
Jonas
Jonas il 8 Mag 2023
thanks for response. the method using CurrentPoint seems to bit slightly better, bit for me it also does not perform perfectly

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by