Twin Axes

I'm creating a twined axes figure and have run into a problem. I need to increase the font size of all the text on the plot, but nothing I do seems to work.

Here's the code I have to generate the plot:

    fig = figure()
    host = HostAxes(fig,[0.08, 0.1, 0.82, 0.83])
    par = ParasiteAxes(host,sharex=host)
    host.parasites.append(par)
    host.set_xlabel('Dominant Characteristic Threshold')
    host.axis['right'].set_visible(False)
    par.axis['right'].set_visible(True)
    host.set_ylabel('Number of Groups')
    par.set_ylabel('% Noise Students')
    par.axis["right"].major_ticklabels.set_visible(True)
    par.axis["right"].label.set_visible(True)
    fig.add_axes(host)
    p1, = par.plot(dom[-1],noise[-1],'-o')
    p2, = host.plot(dom[-1],ngroups[-1],'-s')
    p3, = par.plot([75,100],[.1,.1],'--',color=p1.get_color(),alpha=0.5)
    p4, = par.plot([75,100],[.2,.2],'--',color=p1.get_color(),alpha=0.5)
    p5, = par.plot([75,100],[.3,.3],'--',color=p1.get_color(),alpha=0.5)
    p6, = par.plot([75,100],[.4,.4],'--',color=p1.get_color(),alpha=0.5)
    p7, = par.plot([75,100],[.5,.5],'--',color=p1.get_color(),alpha=0.5)
    p8, = par.plot([75,100],[.6,.6],'--',color=p1.get_color(),alpha=0.5)
    p9, = par.plot([75,100],[.7,.7],'--',color=p1.get_color(),alpha=0.5)
    p10, = par.plot([75,100],[.8,.8],'--',color=p1.get_color(),alpha=0.5)
    host.set_ylim(0,8)
    par.set_ylim(0,0.9)
    host.axis["left"].label.set_color(p2.get_color())
    par.axis["right"].label.set_color(p1.get_color())
    draw()
    filename = 'Figures/%idomthreshold.png' % aa
    savefig(filename,dpi=150)

Things I've tried:
Adding a size keyword argument to the set_xlabel and set_ylabel commands (both numerical and keywords). No errors are raised, but nothing is changed on the plot.

Adding host.axis["left"].set_size(24) and par.axis["right"].set_size('large'), to the code. This raises an AttributeError: 'AxisArtist' object has no attribute 'set_size'

Adding host.set_size(24) and par.set_size('large') to the code. This raises an AttributeError: 'AxesHostAxes' object has no attribute 'set_size'

Any suggestions for how to get the font size larger?

···

--

R. Padraic Springuel
Research Assistant
Department of Physics and Astronomy
University of Maine
Bennett 309
Office Hours: By Appointment Only

host.axis["left"].major_ticklabels.set_size(24)

or

host.axis["left"].label.set_size(24)

should work.

On the other hand, if you're using matplotlib v1.0 or later, I
recommend you to use "axes_grid1" instead of "axes_grid". With
axes_grid1, set_xlable and set_ylable work as expected. For example,
your code can be something like below.

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.parasite_axes import HostAxes

fig = plt.figure()
host = HostAxes(fig,[0.08, 0.1, 0.82, 0.83])
fig.add_axes(host)
par = host.twinx()
host.set_xlabel('Dominant Characteristic Threshold', size=24)
host.set_ylabel('Number of Groups', size=24)
par.set_ylabel(' Noise Students', size=24)

# bunch of plot commands

host.set_ylim(0,8)
par.set_ylim(0,0.9)

Regards,

-JJ

···

On Wed, Aug 4, 2010 at 2:21 AM, R. Padraic Springuel <R.Springuel@...1210...> wrote:

Things I've tried:
Adding a size keyword argument to the set_xlabel and set_ylabel commands
(both numerical and keywords). No errors are raised, but nothing is
changed on the plot.

Adding host.axis["left"].set_size(24) and
par.axis["right"].set_size('large'), to the code. This raises an
AttributeError: 'AxisArtist' object has no attribute 'set_size'

Adding host.set_size(24) and par.set_size('large') to the code. This
raises an AttributeError: 'AxesHostAxes' object has no attribute 'set_size'

Any suggestions for how to get the font size larger?