How to sort heatmap columns based on outside data
2 views (last 30 days)
Show older comments
Hi,
I plotted a heatmap as shown below:
h = heatmap(array);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1006665/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1006670/image.png)
I want to sort my columns based on some outside data, specifically an array called idx shown below. How can I do this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1006675/image.png)
Thanks.
0 Comments
Accepted Answer
Voss
on 21 May 2022
array = rand(13,28);
idx = [13 5 24 23 17 15 3 12 1 25 26 4 18 10 27 14 21 7 20 19 8 28 11 2 6 22 16 9];
h = heatmap(array(:,idx),'XDisplayLabels',sprintfc('%d',idx));
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Distribution 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!