How to left align YDisplayLabels in a heatmap
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have generated a heatmap on MATLAB. The display labels for the y-axis are included in a line that looks like the following:
labels={'aaaa','bbb','c'};
h1=heatmap(rand(3,3));
h1.YDisplayLabels=labels;
I would like the YDisplayLabels to be left aligned in the window and not right-aligned, which is the default. Can you please help me figure out the syntax to do that?
0 commentaires
Réponses (1)
Adam Danz
le 2 Mai 2023
Modifié(e) : Adam Danz
le 2 Mai 2023
You can pad the labels with empty spaces so that all labels are the same length using
labels={'aaaa','bbb','c'};
h1=heatmap(rand(3,3));
drawnow
labelsPadded = pad(labels,max(strlength(labels)));
h1.YDisplayLabels = labelsPadded;
but unless you're using a fixed width font, it may not produce exact right alignment.
h1.FontName = 'consolas';
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!