Dear member, how to plot this figure in Matlab. Many thanks
Kind regards

 採用された回答

Adam Danz
Adam Danz 2019 年 10 月 2 日
編集済み: Adam Danz 2019 年 10 月 2 日

0 投票

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')))

2 件のコメント

Tran Hoa
Tran Hoa 2019 年 10 月 2 日
Thank you so much Adam
Kind regards
Adam Danz
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
Tran Hoa 2019 年 10 月 2 日

0 投票

Dear Adam how to change number 1, 2 (I circur in the figure by name EX: Machine 1). Here my code and file exel
filename = 'Test output ANN alone _ PSO _ IPSO';
sheetname1 = 'Sheet1';
data = xlsread(filename,sheetname1,'B2:D42');
heatmap(data)
xlabel('predicted')
ylabel('actual')
Thank you

6 件のコメント

Adam Danz
Adam Danz 2019 年 10 月 2 日
To change the xtick labels in the demo from my answer,
h = heatmap(data);
labels = sprintfc('%c','a':'t');
h.XData = labels; % <---change labels
Adam Danz
Adam Danz 2019 年 10 月 2 日
Tran Hoa's answer moved here as a comment. Please use the comment sections for discussion and the answer sescions for answer.
Why errors happen when I use this code as your instruction
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)
h = heatmap(data);
labels = sprintfc('%c','a':'t');
h.XData = labels; % <---change labels
Adam Danz
Adam Danz 2019 年 10 月 2 日
編集済み: Adam Danz 2019 年 10 月 2 日
How could I answer that without knowing the error message? Please provide the entire copy-pasted error message and the version of matlab you're using.
Tran Hoa
Tran Hoa 2019 年 10 月 2 日
I used Matlab 2018B. Thank you
Capture.PNG
Tran Hoa
Tran Hoa 2019 年 10 月 2 日
Dear Adam, based on your instruction, I also solved this problem. Thank you so much. Kind regardsCapture.PNG
Adam Danz
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
Tran Hoa 2019 年 10 月 2 日

0 投票

Thank you so much Adam. I’m a beginer, I will try to study more. Kind regards

2 件のコメント

Tran Hoa
Tran Hoa 2019 年 10 月 3 日
Dear Adam, how to plot figure like this, two values (347 and 14.6% or can use words insteads of number in the sheet). Thank you so much.
Capture.PNG
Adam Danz
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:

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeColor and Styling についてさらに検索

タグ

質問済み:

2019 年 10 月 2 日

コメント済み:

2019 年 10 月 3 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by