MATLAB: change the font of XTickLabel, YTickLabel, etc.

In MATLAB, you can change the font name of things like ylabel , xlabel , title , etc. graphics, for example.

 ylabel(y_string, 'FontName', 'Palatino') 

However, is it possible to change the font of XTicks, YTicks, etc.?

+4
source share
4 answers

I used to have fights with teak fonts. I think they usually use the font of the axes, in this case something like:

 set(gca, 'FontName', 'Palatino'); 

must work. If this is unsuccessful, you can try Print format labels from file sharing. It replaces ticks with text objects, so formatting can be fully customized the same as with any text object (I seem to remember that I looked at it a while ago, you may need to crack the code to select a font).

+7
source
 set(gca,'XTickLabel',{labelList}, 'FontSize',8,'FontName','Times') 
+2
source

You need to get the handle of the current axes using the gca :

 set(gca, 'FontName', 'Palatino'); 
+1
source

Answered here: How to change the font size of the x axis?

Here is the answer from this post, thanks to user Marc Manzano. Note that it changes both the font (which you requested) and the font size (as I found this thread):

 plot(X) set(gca, 'FontName', 'Arial') set(gca, 'FontSize', 12) ylabel('Label Y axis') xlabel('Label X axis') 

The important thing is that you execute the set() commands BEFORE the ylabel and xlabel . I don’t know exactly why and how it works, but it worked for me on a logarithmic chart.

+1
source

Source: https://habr.com/ru/post/1412164/


All Articles