How to color a matrix based on the values in matlab?
77 views (last 30 days)
Show older comments
I have a matrix of 9 by 5. I want to colur them in a table so that the higher values got red and the lowest got yellow. The intermediates are needed to be coloured with much less intense colours. So that i can just look into the colured table and can find the extreme values.
Here is a sample matrix
A = [0.7637612466433112,1.1142257017424961,0.2706813336848490,0.6354189964764154,30.6379671624144230,11.8049168799568474,15.7338944060010970,18.0052089219629146,1.5550130243814884
1.0337160657834659,0.9053961299782572,0.0959387221794711,1.2755128591866434,20.2782302123378209,3.3596928189626372,12.8964470817516776,7.8209674022748219,14.7130990449859755
1.0352868473067149,0.8237493570972951,0.6293715485887250,1.4946974606102095,35.3716291208025027,15.1388369125029829,20.4467327402212398,21.3267519051622365,9.5896087462786550
0.7598211259414681,0.6380203614898264,0.6356153065462685,1.8656794106933650,28.7986725951837208,12.1863561285026893,17.7283779444741967,8.2495858566589177,0.5313099762536371
0.9218612009686062,0.8860241669143043,0.2169698158710809,0.4690154360645855,23.0655895502382933,11.7899831056826532,16.1005856458353982,19.3146346480949731,7.7749477864298164]
0 Comments
Accepted Answer
Adam Danz
on 14 Dec 2018
Edited: Adam Danz
on 14 Dec 2018
heatmap(A)
xlabel('column number')
ylabel('row number')
9 Comments
Adam Danz
on 17 Dec 2018
Here are some possible solutions
- just to expand the horizontal size of the figure.
- rotate your matrix if there are much less columns than rows.
- round your values so they only have 1 decimal place - that will make shorter strings.
- just use the color bar to estimate the value of each cell.
More Answers (1)
Image Analyst
on 14 Dec 2018
Sounds like a Yair Altman question.
See his web site: Coloring cells in a uitable
0 Comments
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!