Setting the tick label font size

Hello,

I'm trying to change the font size for the tick labels. I've tried both
setting it explicitly when creating the labels:

  ax2.set_xticklabel(['%d' % x for x in arange(10)], fontsize=10)

or after:

  for label in ax2.get_xticklabels():
      label.set_fontsize(8)

but the rendering is unaffected by the setting. This is with the MacOSX
backend and with the PDF backend. Is it a bug or am I missing something?

Thanks. Best,
Daniele

Hi Daniele,

not sure, but it seems to work for me. Did you do a plt.draw() or plt.show() to reflect the changes?

Kind regards,

Oliver

···

2013/10/28 Daniele Nicolodi <daniele@…120…3138…>

Hello,

I’m trying to change the font size for the tick labels. I’ve tried both

setting it explicitly when creating the labels:

ax2.set_xticklabel([‘%d’ % x for x in arange(10)], fontsize=10)

or after:

for label in ax2.get_xticklabels():

  label.set_fontsize(8)

but the rendering is unaffected by the setting. This is with the MacOSX

backend and with the PDF backend. Is it a bug or am I missing something?

Thanks. Best,

Daniele


Android is increasing in popularity, but the open development platform that

developers love is also attractive to malware creators. Download this white

paper to learn more about secure code signing practices that can help keep

Android apps secure.

http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hello,

it investigated this a bit further and the problem presents itself only
when I use `mpl_toolkits.axisartist.Axes`. Here is a minimum example
that demonstrates the problem:

import numpy as np
import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1 import host_subplot
from mpl_toolkits.axisartist import Axes

x = np.linspace(0, 2*np.pi)
y = np.sin(x)

f = plt.figure()

BUG = True
if BUG:
    ax1 = host_subplot(111, axes_class=Axes)
else:
    ax1 = host_subplot(111, axes_class=Axes)

ax1.plot(x, y)
ax1.set_xlim(0, 2*np.pi)
ax1.set_xticks(np.linspace(0, 2*np.pi, 5))
ax1.set_xticklabels(['%.2f' % x for x in np.linspace(0, 2*np.pi, 5)],
fontsize=8)

plt.draw()
plt.show()

Cheers,
Daniele

···

On 28/10/2013 23:30, Oliver wrote:

Hi Daniele,

not sure, but it seems to work for me. Did you do a plt.draw() or
plt.show() to reflect the changes?