How to create heatmap chart
11 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
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)
% 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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!