![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240829/image.png)
How to plot square diagram
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Adam Danz
2019-10-2
编辑:Adam Danz
2019-10-2
Demo:
data = diag(randi(20,1,20)+40);
heatmap(data)
xlabel('predicted')
ylabel('actual')
%Create colormap that looks like the image in the question
cm = [linspace(1,0,100)', linspace(1,0,100)', linspace(.875,1,100)']; %from [1 1 .875] to [0 0 1]
colormap(cm)
% or just use
% colormap(flipud(colormap('parula')))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240829/image.png)
2 个评论
Adam Danz
2019-10-2
Glad I could help. I just updated the answer to include a colormap that approximates the colormapping in the image in your question.
更多回答(2 个)
Tran Hoa
2019-10-2
6 个评论
Adam Danz
2019-10-2
I see. sprintfc() is an undocumented built-in matlab function. Apparently you have another file with the same name and that file is a script.
That line is just creating fake labels, anyway. You probably already have your own labels. In any case, you can replace that line with this.
labels = strsplit(sprintf('%c ','a':'t'));
labels(end) = []
Tran Hoa
2019-10-2
2 个评论
Adam Danz
2019-10-3
@ Tran Hoa, this thread may become a bit difficult to follow when there are several "answers" posted that are not answer, but discussion. Please use the "comment" section under a particular answer or under the question if you'd like to continue discussion. The "answer" section is for proposing answer to the question stated at the top of the page.
You can't edit the text displayed in a heatmap. Here's a link to some alternatives:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!