Hello
I would like to plot a 3x3 risk matrix Example: 3x3 risk matrix .
Let us assume, I have 5 data points:
risk1: severity1 / frequency1 risk2: severity2 / frequency2 … risk5: severity5 / frequency5
Now I use scatter plot to plot the data. I would like to have a plot with different background Color (please see link). A 3x3 risk matrix: cells 1/1 (bottom left), 1/2, 2/1 in green, cells 1/3, 2/2, 3/1 in yellow and cells 2/3, 3/3 (top right) and 3/2 in red.
What is the most appropriate way?
Thank you.

5 件のコメント

Star Strider
Star Strider 2018 年 9 月 2 日
When I tried to access the link you posted, I got a 404 error.
jonas
jonas 2018 年 9 月 2 日
編集済み: jonas 2018 年 9 月 2 日
You may want to read about heatmap plot. And yes, the link is dead.
Walter Roberson
Walter Roberson 2018 年 9 月 2 日
The content of the URL suggests that it refers to one of the figures in http://www.znrfak.ni.ac.rs/SE-Journal/Archive/SE-WEB%20Journal%20-%20Vol3-3/pdf/3.pdf
Cyrill Baumann
Cyrill Baumann 2018 年 9 月 3 日
Yes, exactly - a 3x3 frequency-severity-plot.
I have to find out if it works with heatmap. I will try. However, ist there a way of simply define colors of the plot background?
Thanks for your contributions.
jonas
jonas 2018 年 9 月 3 日
編集済み: jonas 2018 年 9 月 3 日
You can easily design the coloured matrix and label the grid with imagesc. This is kind of similar to what you are already doing with plot, but you will get a nicer looking matrix. I don't know if there is a built in function, but you may find something on FileExchange

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

 採用された回答

jonas
jonas 2018 年 9 月 3 日
編集済み: jonas 2018 年 9 月 3 日

1 投票

I wrote a template you can use based on imagesc. See attached image for results.
%Define risk matrix 1-3 (1 low - 2 medium - 3 severe)
C=[2 3 3;
1 2 3;
1 1 2];
%Values for each cell
V=[1 2 3;4 5 6;7 8 9]
ax=axes
hold on
%Draw colored grid
[X,Y]=meshgrid(1:size(C,1),1:size(C,2))
h=imagesc(X(:),Y(:),flipud(C))
%Define colors (green, yellow, red)
cmap=[0 1 0;1 1 0;1 0 0];
% Add cell values
str = sprintfc('%d',V(:))
text(X(:),Y(:),str)
% Define row and column labels
RowLabels={'row1','row2','row3'};
ColLabels={'col1','col2','col3'};
% Some axes settings
set(gca,'xtick',unique(X),...
'ytick',unique(Y),...
'yticklabels',RowLabels,...
'xticklabels',ColLabels)
% Add colorbar and describe colors
cb=colorbar(ax,'location','southoutside')
set(cb,'ticks',[1.3 2 2.7],...
'ticklabels',{'Low','Medium','High'},...
'ticklength',0)
box on
set(ax,'layer','top')
colormap(cmap)

5 件のコメント

Cyrill Baumann
Cyrill Baumann 2018 年 9 月 5 日
Thank you very much, this works properly. Now I am trying to implement this code in my GUI (Matlab R2018a App Designer). When I include your code into the App, a separate figure appears (please see attached image). How can I integrate your plot into the Application?
Walter Roberson
Walter Roberson 2018 年 9 月 5 日
You would probably need uiaxes() instead of axes()
jonas
jonas 2018 年 9 月 5 日
Sorry, I dont know much about GUI
Phoumsavath souvannalath
Phoumsavath souvannalath 2022 年 1 月 20 日
how about 3d?
Walter Roberson
Walter Roberson 2022 年 1 月 20 日
Please expand on your question? What is it that you would like to do in 3D ?

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

その他の回答 (1 件)

the cyclist
the cyclist 2018 年 9 月 3 日

0 投票

As stated in the comments, you could use the imagesc command, or you could try the patch command to create each section individually.

カテゴリ

ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by