Plot position in uiaxes not precise?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
chicken vector
le 24 Avr 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
Réponses (0)
Voir également
Catégories
En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!