필터 지우기
필터 지우기

How to plot square diagram

조회 수: 2 (최근 30일)
Tran Hoa
Tran Hoa 2019년 10월 2일
댓글: Adam Danz 2019년 10월 3일
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일
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일
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
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일
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:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by