Plotting Binary Variables using Heat Map

21 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by