Assigning a different colors to NaN while plotting heatmap.
이전 댓글 표시
Hello all
I have a data, let's say 1000X1000 which consists of numerical values and NaN.
I have to generate a heatmap from it for which I am using the inbuilt command in MATLAB. At the same time, I want to assign a different color(different from my spectrum) to all NaN's. According to the documentation (https://in.mathworks.com/help/matlab/ref/matlab.graphics.chart.heatmapchart-properties.html) we can use
h = heatmap(__,'MissingDataColor',[0.8 0.8 0.8])
to achieve the goal but it is not working in my case.
Please help.
댓글 수: 5
Adam Danz
2020년 6월 22일
"It's not working" is vague.
If you're getting an error please share the entire error message. If the color is not changed, please provide a screenshot.
When I try it in r2020a, it works fine.
m = magic(8);
m(randi(64,1,5)) = nan;
heatmap(m,'MissingDataColor',[0.8 0.8 0.8])
Images below show the default color and the changed color.

Vikash Mittal
2020년 6월 22일
Adam Danz
2020년 6월 22일
What version were you using when it didn't work? Did you get an error message?
Vikash Mittal
2020년 6월 23일
Adam Danz
2020년 6월 23일
I had a feeling you were shadowing the main function.
답변 (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!