Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## matplotlib-users

 [Matplotlib-users] pylab, twinx, and displayed coordinates From: Andreas Matthias - 2011-09-23 21:10:33 ```In the following example the coordinates of the mouse cursor displayed in the pylab window belong to the second y-axis. But I would prefer to have the coordinates of the first y-axis to be displayed. Is this possible? import pylab as mpl mpl.plot([1,3,2]) mpl.twinx() mpl.plot([400,50,100]) mpl.show() Ciao Andreas ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Paul Ivanov - 2011-09-24 06:12:40 ```Hi Andreas, On Fri, Sep 23, 2011 at 2:08 PM, Andreas Matthias wrote: > In the following example the coordinates of the mouse > cursor displayed in the pylab window belong to the > second y-axis. But I would prefer to have the coordinates > of the first y-axis to be displayed. Is this possible? yes it is. > import pylab as mpl > > mpl.plot([1,3,2]) > mpl.twinx() > mpl.plot([400,50,100]) > mpl.show() # get the current figure f = mpl.gcf() # Hide the "background" for the first axes, otherwise it will block the second one when we swap f.axes[0].set_frame_on(False) # Swap the axes f.axes.reverse() # Turn on the "background" for the *new* first axes (the one that was created second) f.axes[0].set_frame_on(False) you can also achieve the same effect by changing the zorder of axes - provided that you remember to have turn the frame on for the one that is the furthest back, and turn it off for all others lying on top of it. You can see what happens if you don't do this by omitting the calls to set_frame_on, and then verifying that the second line does not show up (because the original axes' frame patch is blocking it. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Andreas Matthias - 2011-09-24 11:00:29 ```Paul Ivanov wrote: > On Fri, Sep 23, 2011 at 2:08 PM, Andreas Matthias > wrote: >> In the following example the coordinates of the mouse >> cursor displayed in the pylab window belong to the >> second y-axis. But I would prefer to have the coordinates >> of the first y-axis to be displayed. Is this possible? > > yes it is. > >> import pylab as mpl >> >> mpl.plot([1,3,2]) >> mpl.twinx() >> mpl.plot([400,50,100]) >> mpl.show() > > # get the current figure > f = mpl.gcf() > > # Hide the "background" for the first axes, otherwise it will block > the second one when we swap > f.axes[0].set_frame_on(False) > > # Swap the axes > f.axes.reverse() > > # Turn on the "background" for the *new* first axes (the one that was > created second) > f.axes[0].set_frame_on(False) Hmm. I do not get a reversed list of axes. This is the output of the example code below: [, ] [, ] BTW, what's matplotlib.axes.AxesSubplot? I couldn't find this class. Ciao Andreas import pylab as mpl mpl.plot([1,3,2]) mpl.twinx() mpl.plot([400,50,100]) f = mpl.gcf() print f.axes f.axes[0].set_frame_on(False) f.axes.reverse() f.axes[0].set_frame_on(True) print f.axes mpl.show() ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Paul Ivanov - 2011-09-25 06:27:01 ```On Sat, Sep 24, 2011 at 3:59 AM, Andreas Matthias wrote: > Hmm. I do not get a reversed list of axes. This is the output of > the example code below: > > [, ] > [, ] This doesn't seem right - for me that code results in: [, ] [, ] can you try explicitly swapping your axes? f.axes = [f.axes[1],f.axes[0]] instead of the call to reverse? > BTW, what's matplotlib.axes.AxesSubplot? I couldn't find this class. see SubplotBase class and subplot_class_factory function in matplotlib/axes.py best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Andreas Matthias - 2011-09-25 11:50:31 ```Paul Ivanov wrote: > On Sat, Sep 24, 2011 at 3:59 AM, Andreas Matthias > wrote: >> Hmm. I do not get a reversed list of axes. This is the output of >> the example code below: >> >> [, ] >> [, ] > > This doesn't seem right - for me that code results in: > [, > ] > [, > ] > > can you try explicitly swapping your axes? f.axes = > [f.axes[1],f.axes[0]] instead of the call to reverse? Traceback (most recent call last): File "t5.py", line 13, in f.axes = [f.axes[1],f.axes[0]] AttributeError: can't set attribute I've tried it with matplotlib 1.0.1 and 1.1.0. Same error message. Python is 2.6.4. I'm stumped ... Ciao Andreas ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Benjamin Root - 2011-09-25 16:07:33 Attachments: Message as HTML ```On Sunday, September 25, 2011, Andreas Matthias wrote: > Paul Ivanov wrote: > >> On Sat, Sep 24, 2011 at 3:59 AM, Andreas Matthias >> wrote: >>> Hmm. I do not get a reversed list of axes. This is the output of >>> the example code below: >>> >>> [, ] >>> [, ] >> >> This doesn't seem right - for me that code results in: >> [, >> ] >> [, >> ] >> >> can you try explicitly swapping your axes? f.axes = >> [f.axes[1],f.axes[0]] instead of the call to reverse? > > Traceback (most recent call last): > File "t5.py", line 13, in > f.axes = [f.axes[1],f.axes[0]] > AttributeError: can't set attribute > > > I've tried it with matplotlib 1.0.1 and 1.1.0. Same error message. > Python is 2.6.4. > I'm stumped ... > > > Ciao > Andreas > Sometimes installations can get mixed up. What does: Import matplotlib print matplotlib.__version__ print matplotlib.__file__ outputs for your v1.1.0 installation and your v1.0.1 install? Ben Root ```
 Re: [Matplotlib-users] pylab, twinx, and displayed coordinates From: Andreas Matthias - 2011-09-25 16:25:36 ```Benjamin Root wrote: > On Sunday, September 25, 2011, Andreas Matthias > wrote: >> Paul Ivanov wrote: >> >>> On Sat, Sep 24, 2011 at 3:59 AM, Andreas Matthias >>> wrote: >>>> Hmm. I do not get a reversed list of axes. This is the output of >>>> the example code below: >>>> >>>> [, > ] >>>> [, > ] >>> >>> This doesn't seem right - for me that code results in: >>> [, >>> ] >>> [, >>> ] >>> >>> can you try explicitly swapping your axes? f.axes = >>> [f.axes[1],f.axes[0]] instead of the call to reverse? >> >> Traceback (most recent call last): >> File "t5.py", line 13, in >> f.axes = [f.axes[1],f.axes[0]] >> AttributeError: can't set attribute >> >> >> I've tried it with matplotlib 1.0.1 and 1.1.0. Same error message. >> Python is 2.6.4. >> I'm stumped ... > > Sometimes installations can get mixed up. What does: > > Import matplotlib > print matplotlib.__version__ > print matplotlib.__file__ > > outputs for your v1.1.0 installation and your v1.0.1 install? 1.1.0 /home/andreas/local/python/lib/python2.6/site-packages/matplotlib/__init__.pyc This is the right place. Then I removed matplotlib/ and installed it again. But the error stays the same. Ciao Andreas ```