フィルターのクリア

How to create heatmap chart

6 ビュー (過去 30 日間)
Isyraf
Isyraf 2022 年 8 月 16 日
編集済み: Cris LaPierre 2022 年 8 月 16 日
I have dataset of matrix 45x9 with variables 'station' and the other 8 are heavy metals concentration. I want to plot a heatmap to show which station have the highest and lowest concentration, instead in values. The 'station' will be y and the heavy metals concentration will be x. A coding of a heatmap chart of station and one of the the heavy metals concentration would be suffice, but if possible i would like the coding for heatmap chart of station and all the heavy metals.
  1 件のコメント
Isyraf
Isyraf 2022 年 8 月 16 日
Something like this, but 2 column still would be fine. For station and Lithium, for example.

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 8 月 16 日
編集済み: Cris LaPierre 2022 年 8 月 16 日
I would use the following syntax:
You haven't shared your station names, so this approach uses the values in the table (loaded as strings).
fileNm = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099640/HMCSV.csv';
opts = detectImportOptions(fileNm);
opts = setvartype(opts,'Station','string');
data = readtable(fileNm,opts)
data = 44×9 table
Station Lithium Chromium Manganese Iron Copper Zinc Arsenic Lead _______ _______ ________ _________ _______ ______ ______ _______ ______ "37" 8.6933 17.043 31.42 0.43167 7.2967 23.88 0.90333 6.8783 "36" 7.285 14.395 39.4 0.57 7.115 22.765 0.75333 7.32 "35" 7.7 13.127 28.95 0.57667 7.4383 24.7 0.85833 7.8133 "34" 7.93 12.038 33.483 0.39333 6.3717 18.45 0.86333 7.185 "33" 8.725 12.698 42.533 0.32167 5.7483 15.4 1.07 7.2917 "32" 7.37 19.663 27.817 0.30667 4.0317 19.683 1.0167 6.165 "31" 8.0333 17.587 30.7 0.4 4.61 23.25 0.81667 7.415 "30" 8.51 16.963 36.992 0.41333 3.5433 20.87 0.86667 7.295 "29" 8.1567 17.867 33.767 0.46833 4.9833 19.033 0.86333 7.5883 "28" 9.15 19.218 33.967 0.56667 4.405 23.333 1.4167 8.0367 "27" 8.3633 13.497 28.717 0.47833 4.69 26.282 0.96 7.46 "26" 9.56 11.593 36.863 0.52333 4.98 21.958 1.2767 8.7983 "25" 11.983 9.605 49.7 0.55 8.5117 15.57 0.92333 8.2083 "24" 10.657 11.422 43.1 0.40167 5.805 20.7 1.285 8.31 "23" 10.002 12.2 38.367 0.51 4.65 18.417 0.99167 7.4617 "22" 9.6783 13.623 32.333 0.435 6.0417 16.697 1.0067 9.3067
% Create heatmap
heatmap(data.Properties.VariableNames(2:end),data.Station,data{:,2:end})
% Default color is shades of blue. This changes it to blue->black
colormap jet
The values will appear if you make the figure bigger (maximize it on your computer).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by