On Thu, Jun 13, 2013 at 4:47 AM, Daniel Mader <
danielstefanma...@googlemail.com> wrote:

> Hi,
>
> I need a twinx() plot with horizontal and vertical grid lines for the
> second axis, just like the usual grid for the first axis. I don't need or
> want to specify the ticks manually, though!
>
> My example code just produces horizontal lines:
>
> import pylab
>
>
> datax = pylab.arange(50)
>
> data1 = pylab.sin(datax)*1.5
>
> data2 = datax**2
>
>
> pylab.close('all')
>
>
> fig = pylab.figure()
>
> ax1 = fig.add_subplot(111)
>
> ax2 = ax1.twinx()
>
>
> ax1.plot(datax, data1, 'x')
>
> ax2.plot(datax, data2, '--')
>
>
> #ax1.grid()
>
> ax2.grid()
>
>
> fig.show()
>
>
> Thanks in advance!
>

Does this get you where you want to be?

import pylab

datax = pylab.arange(50)
data1 = pylab.sin(datax)*1.5
data2 = datax**2

pylab.close('all')

fig = pylab.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()

ax1.plot(datax, data1, 'x')
ax2.plot(datax, data2, '--')

for ax in [ax1, ax2]:
    ax.xaxis.grid(True, which='both') # `which` can be 'minor', 'major', or
'both'
    ax.yaxis.grid(True, which='both')

fig.show()
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to