Problem with data points in my UIAxes
10 views (last 30 days)
Show older comments
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 Comment
dpb
on 7 Mar 2023
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.
Answers (1)
Kartik
on 18 Apr 2023
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
0 Comments
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!