change Axis ticklabel font size

295 ビュー (過去 30 日間)
MINA
MINA 2016 年 3 月 7 日
コメント済み: BK Shouharda 2021 年 6 月 28 日
I am trying to change the font size of Xticklabel by this code
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',12,'FontWeight','bold')
in a figure where I have 6 subplots and I do this for each subplot separately. However when I get my figure the order of the numbers on the axis are wrong, for example on X axis it shows: [0 500 1000 0 500 1000]. I realized that sometimes if I only set one axis (either X or Y) it would automatically apply on both axis and I don't get this error. But I tried that on each subplot and still doesn't work.
Could you please help me what I can do to solve this issue?

回答 (2 件)

Alexander Cranney
Alexander Cranney 2018 年 10 月 3 日
編集済み: Alexander Cranney 2018 年 10 月 3 日
I was having this same issue. It's easier in 2015B, but some users of my plotting GUI were using 2015A, so I had to figure out how to make it work in 2015A. Try the below code:
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',12,'FontWeight','bold')
set(gca,'XTickLabelMode','auto')
  1 件のコメント
BK Shouharda
BK Shouharda 2021 年 6 月 28 日
Thanks a lot. It really works.

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


Walter Roberson
Walter Roberson 2016 年 3 月 7 日
Every subplot is an axes by itself. Axes do not "contain" subplots: each subplot is a full independent axes that happens to be positioned nicely relative to other axes.
Up to R2014a, the axes fontname property affects the x, y, and z axes at the same time and they cannot be varied independently. The situation for R2014b is a bit confused. As of R2015a, there is are XAxis, YAxis, and YAxis components of axes that can have their FontName properties set independently.
Is it possible that you are using plotyy() or plotxx() ? Those create additional axes that are "below" what is obvious. If you were to set the properties of one of the two plotyy or plotxx axes without setting the other appropriately, you could end up with multiple labels showing up. If you are using plotyy only one of the two x axes should have its XTick set or else you will get duplicate ticks. If you are using plotxx only one of the two y axes should have its YTick set or else you will get duplicate ticks.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by