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 Comment

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().

Sign in to comment.

Answers (0)

Categories

Products

Release

R2018b

Tags

Asked:

on 24 Jan 2019

Commented:

on 24 Jan 2019

Community Treasure Hunt

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

Start Hunting!