tick_left() and tick_right() with minor tick marks

Hi

I have a plot that has two different y-axis scales and I want
appropriate tick marks for the different y-axes. ie I want the tick
marks on the left axis to correspond to the scale on the left axis
etc... As far as I can tell the way to accomplish this, after
consulting the documentation, is to use the tick_left() and
tick_right() methods, I therefore have the following code:

axes1.yaxis.tick_left()
axes1.yaxis.set_major_locator(pylab.MultipleLocator(0.1))
axes1.yaxis.set_minor_locator(pylab.MultipleLocator(0.05))
axes2.yaxis.tick_right()
axes2.yaxis.set_major_locator(pylab.MultipleLocator(5))
axes2.yaxis.set_minor_locator(pylab.MultipleLocator(1))

but the minor ticks are on both the left and right y-axes. How can I
make the minor ticks for axes1 only appear on the the left and the
minor ticks for axes2 appear on the right?

Cheers

Adam

Hi

Anyone know how to fix this problem?

Cheers

Adam

···

On Thu, Jun 19, 2008 at 8:31 PM, Adam Mercer <ramercer@...287...> wrote:

Hi

I have a plot that has two different y-axis scales and I want
appropriate tick marks for the different y-axes. ie I want the tick
marks on the left axis to correspond to the scale on the left axis
etc... As far as I can tell the way to accomplish this, after
consulting the documentation, is to use the tick_left() and
tick_right() methods, I therefore have the following code:

axes1.yaxis.tick_left()
axes1.yaxis.set_major_locator(pylab.MultipleLocator(0.1))
axes1.yaxis.set_minor_locator(pylab.MultipleLocator(0.05))
axes2.yaxis.tick_right()
axes2.yaxis.set_major_locator(pylab.MultipleLocator(5))
axes2.yaxis.set_minor_locator(pylab.MultipleLocator(1))

but the minor ticks are on both the left and right y-axes. How can I
make the minor ticks for axes1 only appear on the the left and the
minor ticks for axes2 appear on the right?

Cheers

Adam

Wasn't this answered by the two_scales.py example?

···

On Monday 23 June 2008 20:53:56 Adam Mercer wrote:

Hi

Anyone know how to fix this problem?

Cheers

Adam

On Thu, Jun 19, 2008 at 8:31 PM, Adam Mercer <ramercer@...287...> wrote:
> Hi
>
> I have a plot that has two different y-axis scales and I want
> appropriate tick marks for the different y-axes. ie I want the tick
> marks on the left axis to correspond to the scale on the left axis
> etc... As far as I can tell the way to accomplish this, after
> consulting the documentation, is to use the tick_left() and
> tick_right() methods, I therefore have the following code:
>
> axes1.yaxis.tick_left()
> axes1.yaxis.set_major_locator(pylab.MultipleLocator(0.1))
> axes1.yaxis.set_minor_locator(pylab.MultipleLocator(0.05))
> axes2.yaxis.tick_right()
> axes2.yaxis.set_major_locator(pylab.MultipleLocator(5))
> axes2.yaxis.set_minor_locator(pylab.MultipleLocator(1))
>
> but the minor ticks are on both the left and right y-axes. How can I
> make the minor ticks for axes1 only appear on the the left and the
> minor ticks for axes2 appear on the right?
>
> Cheers
>
> Adam

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I don't see a problem here. I did the following:

ipython -pylab
run two_scales.py
ax1.yaxis.set_minor_locator(MultipleLocator(1000))
draw()
# Shows minor ticks on both left and right yaxis
ax1.yaxis.tick_left()
draw()
# shows minor ticks on left only
ax2.yaxis.set_minor_locator(MultipleLocator(.1))
draw()
# shows left yaxis minor ticks on left only, shows right yaxis ticks on both
ax2.yaxis.tick_right()
draw()
# shows left yaxis minor ticks on left only, right yaxis minor ticks on
# right only

Darren

···

On Monday 23 June 2008 08:53:56 pm Adam Mercer wrote:

Hi

Anyone know how to fix this problem?

Cheers

Adam

On Thu, Jun 19, 2008 at 8:31 PM, Adam Mercer <ramercer@...287...> wrote:
> Hi
>
> I have a plot that has two different y-axis scales and I want
> appropriate tick marks for the different y-axes. ie I want the tick
> marks on the left axis to correspond to the scale on the left axis
> etc... As far as I can tell the way to accomplish this, after
> consulting the documentation, is to use the tick_left() and
> tick_right() methods, I therefore have the following code:
>
> axes1.yaxis.tick_left()
> axes1.yaxis.set_major_locator(pylab.MultipleLocator(0.1))
> axes1.yaxis.set_minor_locator(pylab.MultipleLocator(0.05))
> axes2.yaxis.tick_right()
> axes2.yaxis.set_major_locator(pylab.MultipleLocator(5))
> axes2.yaxis.set_minor_locator(pylab.MultipleLocator(1))
>
> but the minor ticks are on both the left and right y-axes. How can I
> make the minor ticks for axes1 only appear on the the left and the
> minor ticks for axes2 appear on the right?

I don't see a problem here. I did the following:

ipython -pylab
run two_scales.py
ax1.yaxis.set_minor_locator(MultipleLocator(1000))
draw()
# Shows minor ticks on both left and right yaxis
ax1.yaxis.tick_left()
draw()
# shows minor ticks on left only
ax2.yaxis.set_minor_locator(MultipleLocator(.1))
draw()
# shows left yaxis minor ticks on left only, shows right yaxis ticks on both
ax2.yaxis.tick_right()
draw()
# shows left yaxis minor ticks on left only, right yaxis minor ticks on
# right only

Thanks Darren, that solves it. I was calling tick_left() and
tick_right() before calling set_{major,minor}_locator(). Moving these
calls to after the ticks have been set solves the problem.

Cheers

Adam

···

On Wed, Jun 25, 2008 at 7:21 AM, Darren Dale <dsdale24@...287...> wrote:

Darren