Making tick marks of a secondary axis line up with the primary axis

Hi there,
I'm trying to make a plot with two y axes. I'm able to do that no problem,
but what I'd really like to do now is make the tick marks line up for them
both so that they both use the same grid. Is there a simple way to do this?
Basically, I want to force the number of tick marks on the right hand axis
to be the same as on the left hand axis, and I'd like it to select "nice
numbers" to do so (ie not intervals of .358 or something).

Also, on a somewhat related note, is there a simple way to force the y ticks
to start at 0 rather than some other value?

Thanks a lot,
Alex

···

--
View this message in context: http://old.nabble.com/Making-tick-marks-of-a-secondary-axis-line-up-with-the-primary-axis-tp27854166p27854166.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

From: Alex S [mailto:schmitt.happens@…287…]
Hi there,
I'm trying to make a plot with two y axes. I'm able to do that no
problem,
but what I'd really like to do now is make the tick marks line up for
them
both so that they both use the same grid. Is there a simple way to do
this?
Basically, I want to force the number of tick marks on the right hand
axis
to be the same as on the left hand axis, and I'd like it to select "nice
numbers" to do so (ie not intervals of .358 or something).

Hey Alex,

I always just figure this out on my own. There might exist a more elegant way though.
Starting with this:

import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
# plot stuff

# So then you could do something like:
ytx1 = ax1.get_yticks()

...and then use to len(ytx1) and range() to ax2.set_yticks(blahblah).
The tricky part is picking a max for your range() so that your stepsize produces nice numbers.

Also, on a somewhat related note, is there a simple way to force the y
ticks
to start at 0 rather than some other value?

ax1.set_ylim(ymin=0)

HTH,
-paul h.

···

-----Original Message-----

Ah, that worked fine. Thanks a lot.
Alex

···

--
View this message in context: http://old.nabble.com/Making-tick-marks-of-a-secondary-axis-line-up-with-the-primary-axis-tp27854166p27855043.html
Sent from the matplotlib - users mailing list archive at Nabble.com.