Effacer les filtres
Effacer les filtres

Plotting Binary Variables using Heat Map

17 vues (au cours des 30 derniers jours)
Tochi Nwachukwu
Tochi Nwachukwu le 19 Jan 2023
Réponse apportée : Varun le 21 Fév 2023
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

Réponse acceptée

Varun
Varun le 21 Fév 2023
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

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by