Problem with data points in my UIAxes

조회 수: 10 (최근 30일)
Pas
Pas 2023년 3월 7일
답변: Kartik 2023년 4월 18일
Hello everyone,
I have a problem with my UIAxes in my AppDesigner. When I want to select a datapoint in my plot, my mouse position doesnt match my data point (Image1.). If I use the same code in my Run Sript everything works (Image2.)
Image1 (GUI, check mouse position):
Image2 (Matlab Script):
Here the matlab code:
figure;
[X, Y] = meshgrid(IN.range2, IN.range1);
RES2 = RES';
fig = scatter(Y(:), X(:),[],RES2(:),'filled');
xlabel(replace(IN.param1,'_',' ')); ylabel(replace(IN.param2,'_',' '));
zlabel(replace(result,'_',' '));
hcb = colorbar;
colorTitleHandle = get(hcb,'Title');
set(colorTitleHandle,'String',replace(result, '_', ' '))
fig.DataTipTemplate.DataTipRows(1).Label = replace(IN.param1, '_', ' ');
fig.DataTipTemplate.DataTipRows(2).Label = replace(IN.param2, '_', ' ');
dtRows = [dataTipTextRow(replace(result,'_',' '), RES')];
fig.DataTipTemplate.DataTipRows(end) = dtRows;
clear RES2
I like to work with extra Labels for my Data points, because I often do simulations with more than 2 parameters.
It would help me a lot if someone knows how to fix this bug.
Best Regards
  댓글 수: 1
dpb
dpb 2023년 3월 7일
For anybody here to have any hope of answering this would require you posting a complete working example that duplicates the problem on your end.

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

답변 (1개)

Kartik
Kartik 2023년 4월 18일
Hi,
It seems that the issue you are encountering is related to the difference between the coordinate systems of the UIAxes object in App Designer and a regular figure. To fix this, you can use the 'normalized' units for your scatter plot and then convert the mouse position to the data coordinates.
Here is the link to the MathWorks documentation on the 'normalized' units in UIAxes: https://www.mathworks.com/help/matlab/ref/matlab.ui.control.uiaxes-properties.html#d123e520428

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by