Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the font size of ticks of axes object in matplotlib [duplicate]

I have a figure I added subfigure to (inset). I have used:

fig = plt.figure()
ax = fig.add_subplot(111)
subA = fig.add_axes([0.4,0.14,0.2,0.2])

I now want to change the xtick font size of the subfigure. I tried some naive approach such as

subA.get_xaxis().get_xticks().set_fontsize(10)

without any luck.

How can I do this then?

like image 877
Yotam Avatar asked Oct 30 '12 13:10

Yotam


People also ask

How do I increase the font size of axis values in Matplotlib?

Plot x data points using plot() method. To change the font size of the scale in matplotlib, we can use labelsize in the ticks_params()method. To display the figure, use show() method.

How do I increase ticks in Matplotlib?

Setting Figure-Level Tick Frequency in Matplotlib You can use the xticks() and yticks() functions and pass in an array denoting the actual ticks. On the X-axis, this array starts on 0 and ends at the length of the x array. On the Y-axis, it starts at 0 and ends at the max value of y .


2 Answers

fig = plt.figure() ax = fig.add_subplot(111) plt.xticks([0.4,0.14,0.2,0.2], fontsize = 50) # work on current fig plt.show() 

the x/yticks has the same properties as matplotlib.text

like image 28
lucasg Avatar answered Sep 24 '22 04:09

lucasg


Use:

subA.tick_params(labelsize=6) 
like image 65
gpano Avatar answered Sep 21 '22 04:09

gpano