フィルターのクリア

Plotting Binary Variables using Heat Map

17 ビュー (過去 30 日間)
Tochi Nwachukwu
Tochi Nwachukwu 2023 年 1 月 19 日
回答済み: Varun 2023 年 2 月 21 日
I do need assitance plotting binary variables using heatmap. Please attached data sheet
The plot generated from the code below is not what want.
Mpower4 = readtable('file.xls','Sheet','Connectivity','ReadRowNames',true,'EmptyValue',0,"TextType","string" );
Vars = {{'g1','g2','g3'},{'G2crank','G3crank'},{'n1','n2','n3','n4','n5','n6','n7','n8','n9'},{'l1','l2','l3','l4','l5','l6','l7','l8','l9'}};
s5=stackedplot(Mpower4,Vars);
s5.LineProperties(1).PlotType = "stem";
s5.LineProperties(2).PlotType = "stairs";
s5.LineProperties(3).PlotType = "stairs";
s5.LineProperties(4).PlotType = "stairs";
ax3 = findobj(s5.NodeChildren, 'Type','Axes');
set(ax3, 'YTick', [0 1]);
s5.AxesProperties(1).YLimits = [-0.5 1.5];
s5.AxesProperties(2).YLimits = [-0.5 1.5];
s5.AxesProperties(3).YLimits = [-0.5 1.5];
s5.AxesProperties(4).YLimits = [-0.5 1.5];
s5.LineWidth = 2;
s5.XLabel ='Minutues'
grid on

採用された回答

Varun
Varun 2023 年 2 月 21 日
Hello!
To plot a heatmap of binary variables, you can convert the table data to a matrix (array) first and then, call the heatmap function directly. Check out the following code:
Mpower4 = readtable('matlabhelp.xlsx','Sheet','Sheet1','ReadRowNames',true,'EmptyValue',0,"TextType","string" );
mp4=Mpower4{:,:};
xvalues={'g1','g2','g3','G2crank','G3crank','n1','n2','n3','n4','n5','n6','n7','n8','n9','l1','l2','l3','l4','l5','l6','l7','l8','l9'};
yvalues=1:14;
h=heatmap(xvalues,yvalues,mp4);
For more information about heatmaps on MATLAB, check out the following documentation: https://www.mathworks.com/help/matlab/ref/heatmap.html#bvlbhnq-1
Hope this helps!Heatmap of binary variables

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by