Getting a point from a heatmap.

I create a heatmap, but would then like to be able to click a point and have this create a variable of the x and y labels at this point.
for example:
a = [ 0.7143 1.6667 1.2500 1.4286 0 0 0
0.7143 0 0 1.8750 1.4286 1.4286 2.5000
0 0 0.7143 0.5556 0.8333 0.7143 0
1.0000 0 0.7143 1.2500 0.7143 1.4286 0];
heatmap(a)
When I create this heatmap I can hover my mouse over a box to give the X and Y coordinates, but how can I click to create these as a variable?

1 个评论

Heatmap is a special plot that does not share the same set of properties as many other plots. For example, in a regular plot, you can right click anywhere on an axis and select "Export Cursor Data to Workspace" which will store the selected coordinate to a variable in your workspace. However, when you right click on a heatmap, nothing happens.
One way around this is to use imagesc() instead of heatmap() but then you lose some of the features that are helpful in heatmap().

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Distribution Plots 的更多信息

产品

版本

R2018b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by