Effacer les filtres
Effacer les filtres

Problem with data points in my UIAxes

2 vues (au cours des 30 derniers jours)
Pas
Pas le 7 Mar 2023
Réponse apportée : Kartik le 18 Avr 2023
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 commentaire
dpb
dpb le 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.

Connectez-vous pour commenter.

Réponses (1)

Kartik
Kartik le 18 Avr 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

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by