How do I remove the tick marks on a bar plot at the top and the right?

31 ビュー (過去 30 日間)
L'O.G.
L'O.G. 2023 年 1 月 22 日
コメント済み: Star Strider 2023 年 1 月 22 日
I can do this by box off but that also removes the lines. How can I keep the lines on the top and the right of the plot, but just remove the ticks there?
EDIT: The data in x is an array of variables of type categorical, which led to an error as indicated in a comment to one of the answers. The following leaves an undesirable gap at the beginning and end at the top of the plot:
Ax = gca;
Ax.Box = 'off';
xlim = get(gca,'xlim');
ylim = get(gca,'ylim');
line([xlim(1) xlim(2)],[ylim(2) ylim(2)])

採用された回答

Star Strider
Star Strider 2023 年 1 月 22 日
Turn the Box property 'off', then use xline and yline to draw the lines —
figure
bar(rand(1,10))
Ax = gca;
Ax.Box = 'off';
xline(max(xlim))
yline(max(ylim))
.
  4 件のコメント
L'O.G.
L'O.G. 2023 年 1 月 22 日
Thank you! Wonderful.
Star Strider
Star Strider 2023 年 1 月 22 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFormatting and Annotation についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by