How can I change the font size of the current axis?

2,711 ビュー (過去 30 日間)
Hassan
Hassan 2011 年 6 月 15 日
コメント済み: Rhythm Analyst 2022 年 10 月 26 日
How can I change the font size of the axes of the current graph without creating new axes? For example, if we have this plot already, how can I change the font size?
x = rand(10,10);
y = rand(10,10);
plot(x,y)

採用された回答

Matt Fig
Matt Fig 2022 年 4 月 28 日
編集済み: MathWorks Support Team 2022 年 4 月 28 日
To change the font size, set the FontSize property on the axes object after plotting. For example:
x = rand(10,10);
y = rand(10,10);
plot(x,y);
set(gca,FontSize,20)
Starting in R2022a, you can use the “fontsize” function to change the font size for any graphics object that has text associated with it. In this case, pass the axes object to the “fontsize” function followed by the desired font size in points. For example:
fontsize(gca,20)
You can also change the font name using the “fontname” function. The font you specify must be installed on your system. For example, change the font of the current axes to Courier:
fontname(gca,"Courier")
  3 件のコメント
Viktor Erdelyi
Viktor Erdelyi 2022 年 5 月 16 日
On my end, I had to specify the fontsize unit as shown here.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 5 月 16 日
See attached demo to see how you can independently change a wide variety of things in your axes.
  3 件のコメント
Rhythm Analyst
Rhythm Analyst 2022 年 10 月 26 日
Solved the issue; I was using ax=gca; for both 'yyaxis left' and 'yyaxis right'. Fix was to have ax1 for left yaxis and ax2 for right yaxis; as far as I can tell thats what fixed it anyway...
Thanks for the response.

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

カテゴリ

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by