Problem with data points in my UIAxes

4 次查看(过去 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