Effacer les filtres
Effacer les filtres

Xticklabels not labelling appropriate bars in barplot

30 vues (au cours des 30 derniers jours)
Daniel Goldstein
Daniel Goldstein le 24 Mar 2022
Commenté : Voss le 24 Mar 2022
I'm trying to label the Xticks on a bar chart to show variable importance. There are 20 variable bars. However, only some are showing xtick labels and they're lininig up with the respective bar. Looks like they're skipping and not aligning.For instance, 'rop' isn't aligned with the first bar despite being the first variable name.
I've tried to expand the figure to a full window but get the same result (second screengrab).
What needs to be done to label each x tick with the respective variable name?

Réponse acceptée

Voss
Voss le 24 Mar 2022
Modifié(e) : Voss le 24 Mar 2022
If you're setting the XTickLabel you generally should also be setting the XTick:
h = gca;
h.XTick = 1:20;
h.XTickLabel = Mdlucs.PredictorNames;
  2 commentaires
Daniel Goldstein
Daniel Goldstein le 24 Mar 2022
Thank you. That did the trick.
Voss
Voss le 24 Mar 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D 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