Xticklabels not labelling appropriate bars in barplot

20 ビュー (過去 30 日間)
Daniel Goldstein
Daniel Goldstein 2022 年 3 月 24 日
コメント済み: Voss 2022 年 3 月 24 日
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?

採用された回答

Voss
Voss 2022 年 3 月 24 日
編集済み: Voss 2022 年 3 月 24 日
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 件のコメント
Daniel Goldstein
Daniel Goldstein 2022 年 3 月 24 日
Thank you. That did the trick.
Voss
Voss 2022 年 3 月 24 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by