Probing a plot based on colormap information

12 次查看(过去 30 天)
How can I probe a plot with colormap data?
As you see, in this case, it only shows the xyz coordinates which is not really useful. I want to be able to see the colormap value (between 0 and 1).
Any ideas? I am using the trisurf function.

采纳的回答

Simon Chan
Simon Chan 2022-3-11
Try function datatip & dataTipTextRow if your MATLAB version is after 2019b.
[x,y] = meshgrid(1:15,1:15);
z = peaks(15);
T = delaunay(x,y);
s = trisurf(T,x,y,z);
dt = datatip(s);
s.DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Colormap Value',T,'%.1f');
  9 个评论
Simon Chan
Simon Chan 2022-3-11
Add another line :-)
s.DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Colormap Value',repmat(s.CData,1,3),'%.3f');
s.DataTipTemplate.DataTipRows(1:3)=[]; % Add this line as well
delete(dt);

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2022-3-10
I don't think you would be able to see the values like that. But you can see what value it has using:
F = scatteredInterpolant(x,y,z,c) ;
ci = F(xi,yi,zi) ; % where xi, yi, zi is the picked point
  5 个评论
Simon Chan
Simon Chan 2022-3-10
Choose figure object
f = figure;
ax = gca;
d = datacursormode(f)
d =
DataCursorManager with properties: SnapToDataVertex: on DisplayStyle: 'datatip' DefaultExportVarName: 'cursor_info' Interpreter: 'tex' UpdateFcn: [] Enable: off Figure: [1×1 Figure]
d2 = datacursormode(ax)
Error using datacursormode (line 154)
Invalid figure handle
Pelajar UM
Pelajar UM 2022-3-10
Thanks, but how do you get the figure object of an UIAxes in app designer?
trisurf(F,P(:,1),P(:,2),P(:,3), flow12, 'Parent', app.UIAxes2_10);
c = colorbar(app.UIAxes2_10);
caxis(app.UIAxes2_10,[0.333 1]);
colormap(app.UIAxes2_10, jet);
c.Label.String = 'T11 Tensor';
On another note, there seems to be a way to modify the data tip function, but I don't really know how to implement customized functions in app designer:

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by