Plot position in uiaxes not precise?

조회 수: 4 (최근 30일)
Jonas
Jonas 2023년 4월 24일
댓글: Jonas 2023년 5월 8일
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
chicken vector
chicken vector 2023년 4월 24일
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 2023년 5월 8일
thanks for response. the method using CurrentPoint seems to bit slightly better, bit for me it also does not perform perfectly

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by