how to create a graphic-table point correspondence

1 visualizzazione (ultimi 30 giorni)
Hello everyone,
I hope someone could help me with the following problem.
I have a set of points with (x,y) coordinates. I plotted them in a scatter graph. I would like to create a relation between points on the graph and those in the table, so that when I click one point on the graph, the corresponding point (x,y coordinates) in the table is highlighted.
Is it possible to do it?
Below, my code:
%quadratic curve
t = @(x,y) a.*x.^2 + b.*x.*y + c.*x + d.*y.^2 + e.*y + f
a = -0.0075
b = -0.1197
c = -1.6263
d = 0.0898
e = 1.1847
f = 0.2420
zhandle1 = fcontour(t)
zhandle=fcontour(t, [0 1], 'LevelList', 0)
hold off
M = zhandle.ContourMatrix
M1 = transpose(M)
T = array2table(M1, 'VariableNames',{'Xnorm','Ynorm'})
T.Variables = round(T.Variables,3);
T(1,:) = []
x1 = M(1,(2:122))
y1 = M(2,(2:122))
scatter(x1,y1)
In other words,
When I click on one random point in the graph I can see the coordinates x, y. Could I extract or to note these coordinates, corresponding to the point choosed on the graph, from the table?
Thank you very much in advance for you time and help.
Regards
Laura

Risposte (1)

Srijith Kasaragod
Srijith Kasaragod il 29 Ott 2021
Hi Laura,
You can use 'uitable' function to add a table into the figure and position it below the scatter plot using 'Position' property. Populate your table from workspace into the figure by assigning 'Data' field of uitable. Then using 'datacursormode' and 'getCursorInfo' functions, you can extract the value being clicked on the plot and perform a search on the uitable to identify and highlight the row corresponding to the point.
Refer this question to know how to extract user click from the plot. Additionally, refer this question to know how to programmatically scroll and select a row from uitable.
Hope this helps.

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by