yticks on the right and label size

Hi,

I have a problem with plotting two different quantities on the same plot (overlaying two different axes).
I plot two different quantities, with different scales, on two overlapping axes. So, I want the quantity 1 to refer to the y axis on the left (with its ticks and labels), and quantity 2 to refer to the y axis on the right (with its ticks and labels). I choose on which side I want the ticks with ax.yaxis.tick_left(). Anyway, if I want then to change the label size of the right y axis, I can't do that. I included a sample plot.

My code is something like this:

F = figure()
#First quantity
AX1 = F.add_axes(rect)
AX1.plot(x1,y1)
AX1.yaxis.tick_left() #with this I say quantity 1=left y axis
AX1.set_yticks(range(2,14,2))
AX1.set_yticklabels(range(2,14,2),size=20)
#Second quantity (with different scale)
AX2 = F.add_axes(rect,frameon=False)
AX2.plot(x2,y2)
AX2.yaxis.tick_right() #If I leave this line, I can't change the tick label size, if I remove it, I get ticks on both sides
AX2.set_yticks(np.arange(16.8,18.8,0.4))
AX2.set_yticklabels(np.arange(16.8,18.8,0.4),size=20,position=(1.08,0))

Any ideas?

Thanks,

Andrea

fig_wrong1.pdf (49.9 KB)

Instead of tick_right() try:

AX2.yaxis.set_ticks_position('right')

Ryan

ยทยทยท

On Tue, Jan 18, 2011 at 2:52 AM, <g.plantageneto@...3402...> wrote:

Hi,

I have a problem with plotting two different quantities on the same plot (overlaying two different axes).
I plot two different quantities, with different scales, on two overlapping axes. So, I want the quantity 1 to refer to the y axis on the left (with its ticks and labels), and quantity 2 to refer to the y axis on the right (with its ticks and labels). I choose on which side I want the ticks with ax.yaxis.tick_left(). Anyway, if I want then to change the label size of the right y axis, I can't do that. I included a sample plot.

My code is something like this:

F = figure()
#First quantity
AX1 = F.add_axes(rect)
AX1.plot(x1,y1)
AX1.yaxis.tick_left() #with this I say quantity 1=left y axis
AX1.set_yticks(range(2,14,2))
AX1.set_yticklabels(range(2,14,2),size=20)
#Second quantity (with different scale)
AX2 = F.add_axes(rect,frameon=False)
AX2.plot(x2,y2)
AX2.yaxis.tick_right() #If I leave this line, I can't change the tick label size, if I remove it, I get ticks on both sides
AX2.set_yticks(np.arange(16.8,18.8,0.4))
AX2.set_yticklabels(np.arange(16.8,18.8,0.4),size=20,position=(1.08,0))

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Instead of tick_right() try:

AX2.yaxis.set_ticks_position('right')

Unfortunately this doesn't solve the problem (if it matters, I run matplotlib version 0.99 from Fedora 13).