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!