![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/767011/image.png)
How to know the value of my point on the colorbar?
5 次查看(过去 30 天)
显示 更早的评论
So I have a complicated 3D plot with a colorbar. The colorbar gives me an indication what the temperature is like in a certain region, but it doesn't quite give me a specific number. So how can I get the colorbar to tell me a specific point's temperature? Or is there any other way to get the point's temperature using other means than the colorbar.
0 个评论
采纳的回答
Kevin Holly
2021-10-14
x = 0.1:0.01:0.19;
y = 0.1:0.01:0.19;
z = 0.1:0.01:0.19;
[X, Y, Z] = meshgrid(x, y, z);
f = X.*exp(X.^2 + Y.^2 + Z.^2);
figure
slice(f,5,5,5)
colorbar
figure
for i = 1:10
for j = 1:10
for k = 1:10
scatter3(i,j,k,80*(f(i,j,k)/max(max(max(f)))),f(i,j,k),'filled')
hold on
end
end
end
colorbar
You can go to Tools>Data Tips on the figure's menu as such:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/767011/image.png)
Then select the datapoint that you are interested in. Then you can type this in your command window:
f(7,9,10)
Or if you can retrieve the coordinates of the datatip and use the following commands:
dt = findobj(gca,'Type','datatip') %Where gca (get current Axes) gives you the axes handle of the current axes.
f(dt.X,dt.Y,dt.Z)
If you need to do this frequently, you could make an app with a callback function that automaticaly displays the f value of the given datatip.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!