2014-02-09 2:29 GMT+01:00 garyr <ga...@fidalgo.net>: > The 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()
plt.grid() affects the current axes so calling it before creating the second one should do. I think it would be more consistent if you used the method ax1.grid() though. Goyo ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users