Hi Gary
To get more control on which grid shows / doesn't, you can do:
ax1.grid('on')
ax2.grid('off')
instead of:
plt.grid()
Nico
···
On 9/02/2014, at 5:34 pm, matplotlib-users-request@lists.sourceforge.net wrote:
Message: 1
Date: Sat, 8 Feb 2014 17:29:16 -0800
From: "garyr" <garyr@...4486...>
Subject: [Matplotlib-users] twinx and grid
To: <matplotlib-users@lists.sourceforge.net>
Message-ID: <4ADC6E5C7E0B41E48913F2C42408B5E6@...4487...>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=originalThe script below labels both the left and right x-axes and shows a grid. Is
there a way to force the horizontal grid lines to line up with the tic marks on
the left axis (ax1)?import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
t = np.arange(0.01, 10.0, 0.01)
s1 = np.exp(t)
ax1.plot(t, s1, 'b-')
ax2 = ax1.twinx()
s2 = np.sin(2*np.pi*t)
ax2.plot(t, s2, 'r')
plt.grid()
plt.show()
--
Dr. Nicolas Fauchereau
Climate Scientist – National Climate Centre
National Institute of Water and Atmospheric Research (NIWA) Ltd.
41 Market Place
Viaduct Precinct, Auckland
NEW ZEALAND
Tel: +64 (0)9 375 2053