How to remove values from HEATMAP
이전 댓글 표시
I have data which have 4 column 14 rows, every value in table represent {NO, MIN, MAJ, MOD, COL} you can see the table in attach excel file. For developing heatmap I have converted these value into numbers such as (NO=0, MIN=0.25, MOD=0.50, MAJ=075, COL=1). I have developed the heat map the code is given below. I have 2 doubts regarding this
A) How to remove the values from the heatmap?
B) How to replace the numeric value with again {NO, MIN, MAJ, MOD, COL}. Ans also how to create a colorbar which shows color change with label {NO, MIN, MAJ, MOD, COL}.
Basically these are damage states means its increasing from NO to COL
%MATLAB CODE
s = [0, 1, 2, 3.6];
% file = "D:\OneDrive\WORK\VALID\value.xlsx";
file = "value.xlsx";
valueMap = containers.Map({'No', 'Min', 'Mod', 'Maj', 'Col'}, [0.00, 0.25, 0.5, 0.75, 1.00]);
tableData = readtable(file, 'ReadVariableNames', false);
numericData = zeros(size(tableData));
for i = 1:size(tableData, 1)
for j = 1:size(tableData, 2)
cellValue = char(tableData{i, j}); % Convert cell value to a string
if isKey(valueMap, cellValue)
numericData(i, j) = valueMap(cellValue);
else
numericData(i, j) = NaN;
end
end
end
disp(numericData);
vel = [4 4.25 4.5 4.75 5 5.25 5.5 5.75 6 6.25 6.5 6.75 7 7.25];
nColors = 256; % Number of colormap colors
customColormap = [linspace(1, 1, nColors)', linspace(0.8, 0, nColors)', linspace(0.8, 0, nColors)'];%RED
vel = fliplr(vel);
numericData = flipud(numericData);
h = heatmap(s, vel, numericData,'FontName', 'Times New Roman','fontsize',12);
colormap(customColormap);
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

