Matlab, can you create a separate font size for the x tick mark label and y tick mark label?

29 ビュー (過去 30 日間)
Matlab, I would like the font sizes to be independent for all the axis attributes. Currently, the x and y axis labels must be the same size, and the tick labels for each axis must be the same size. I would like to have the x tick labels be size 12 and the y tick labels be size 20. I'd imagine that someone out there is interested in doing something similar for the axis labels also. While that is a long term fix, my current problem is that the greek letter pi displays at about half the height of numbers. While I am aware that I can put a text box in with a different font size, that isn't really an efficient solution.
Thanks,
dack

採用された回答

Adam
Adam 2016 年 8 月 10 日
編集済み: Adam 2016 年 8 月 10 日
If you are using R2015b or later you can do the following:
hAxes.XAxis.FontSize = 12;
hAxes.YAxis.FontSize = 20;
for an axes handle hAxes.
  1 件のコメント
David
David 2016 年 8 月 10 日
Hello,
Thank you for this answer. It is more convenient to address the axes properties through a structure system. However, the following command: hAxes.YAxis.FontSize = 20; sets the entire group of fonts of the Y axis to 20. So the tick labels will display at a font of 20 (which is what I wanted), unfortunately, the Y axis label is now 22. Ideally, I would like the Y axis label to be font 18. I could set the LabelFontSizeMultiplier to something else, but this will change the ratio between the XTickLabel font and the X axis Title font. So, I am still stuck with one too few variables.
Ideally, I would get: YTick label size: 20 Y Axis Label size: 18 XTick label size: 12 X Axis Label Size: 18
I'm not sure if this is possible.
Axis label size is related to axis font size through a constant multiplier. Tick label size is related to axis font size through a constant multiplier. I need another degree of freedom.
dack

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

その他の回答 (1 件)

Robert
Robert 2016 年 8 月 10 日
編集済み: Robert 2016 年 8 月 10 日
In R2016a (and probably anything R2014b or after), you can set different font sizes for each axis using
ax = gca;
ax.XAxis.FontSize = 12;
ax.YAxis.FontSize = 20;
To get a separate font size within a single label (if you use the default 'tex' interpreter) use
'2\fontsize{32}\pi' % or whatever font size you prefer
You could also use a secondary label to indicate that your values are multiples of pi using
set(ax.XAxis.SecondaryLabel,'Visible','on','String','\times\pi','FontSize',22)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by