How to find data displayed in pcolor using coordinates?
Show older comments
Hi all,
I am trying to find the value displayed by pcolor in a specific coordinate.
rng(1)
z = randn(11);
x = -5:5;
y = -5:5;
[X, Y] = meshgrid(x,y);
xq = 1.25;
yq = 2.34;
pcolor(x,y,z);
hold on
scatter(xq,yq, 'k', 'filled');
How can I find the z-value at the point xq, yq?
I have been banging my head against the wall and can't figure it out.
Accepted Answer
More Answers (1)
Paras Patel
on 18 Mar 2021
rng(1)
z = randn(11);
x = -5:5;
y = -5:5;
[X, Y] = meshgrid(x,y);
xq = 1.25;
yq = 2.34;
hP = pcolor(x,y,z);
hold on
scatter(xq,yq, 'k', 'filled');
dt = datatip(hP,0,0);
hP.DataTipTemplate.DataTipRows(3).Value = hP.CData;
One way to do this would be to insert a datatip on the image. See the code above - it's crude but simple.
Categories
Find more on 2-D and 3-D Plots 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!