Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread Ben Axelrod
Works for me!  Although I did not test with Jorges's original code which caused 
the regression.

Do you still want me to file a bug report so the issue is tracked?  

Thanks,
-Ben

-Original Message-
From: John Hunter [mailto:jdh2...@gmail.com] 
Sent: Monday, February 01, 2010 5:47 PM
To: Jae-Joon Lee
Cc: Ben Axelrod; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Label picker broken?
Importance: Low

On Mon, Feb 1, 2010 at 4:34 PM, John Hunter  wrote:
> On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee  wrote:
>
>> I agree.
>> Unfortunately, event handling is not my specialty, and given no 
>> response from other developers, I recommend you file a bug (and hope 
>> other developers fix this).
>
> I wrote the original functionality and example and do consider this a 
> regression, so do file a bug report and I'll try and get it fixed.

Here is the bug report and fix that caused the current regression


http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg11806.html

The solution I propose is to do the axes comparison test only when the 
mouseevent.inaxes is not None (which happens when you are outside the axes 
rectangle).  Then you could pick artists associated with an axes that are 
outside the rectangle, and still not get confused between two different axes 
with the same coord system.

Try svn r8106.

JDH

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread John Hunter
On Mon, Feb 1, 2010 at 4:34 PM, John Hunter  wrote:
> On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee  wrote:
>
>> I agree.
>> Unfortunately, event handling is not my specialty, and given no response
>> from other developers, I recommend you file a bug (and hope other developers
>> fix this).
>
> I wrote the original functionality and example and do consider this a
> regression, so do file a bug report and I'll try and get it fixed.

Here is the bug report and fix that caused the current regression


http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg11806.html

The solution I propose is to do the axes comparison test only when the
mouseevent.inaxes is not None (which happens when you are outside the
axes rectangle).  Then you could pick artists associated with an axes
that are outside the rectangle, and still not get confused between two
different axes with the same coord system.

Try svn r8106.

JDH

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread John Hunter
On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee  wrote:

> I agree.
> Unfortunately, event handling is not my specialty, and given no response
> from other developers, I recommend you file a bug (and hope other developers
> fix this).

I wrote the original functionality and example and do consider this a
regression, so do file a bug report and I'll try and get it fixed.

JDH

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread Jae-Joon Lee
On Mon, Feb 1, 2010 at 4:30 PM, Ben Axelrod  wrote:

> This still seems like a regression bug to me.  Especially since
> matplotlib's own example code clearly shows that picking labels, titles, and
> tick labels outside the axes region should be possible with the standard
> picker.  If the current picker behavior is the desired behavior, then the
> example code should at least be updated to show the new way to pick objects
> outside the axes.
>

I agree.
Unfortunately, event handling is not my specialty, and given no response
from other developers, I recommend you file a bug (and hope other developers
fix this).

Regards,

-JJ
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread Ben Axelrod
Thanks for the workaround.  I got it to work for the labels and title, but not 
axes tick labels.

This still seems like a regression bug to me.  Especially since matplotlib's 
own example code clearly shows that picking labels, titles, and tick labels 
outside the axes region should be possible with the standard picker.  If the 
current picker behavior is the desired behavior, then the example code should 
at least be updated to show the new way to pick objects outside the axes.

Thanks again,
-Ben


From: Jae-Joon Lee [mailto:lee.j.j...@gmail.com]
Sent: Monday, February 01, 2010 3:48 PM
To: Ben Axelrod
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Label picker broken?

Current "pick" implementation  explicitly checks if the event is inside the 
axes.
So, you cannot pick artists outside the axes area. This seems more like an 
intended "feature" than a bug, but I may be wrong. And my guess is that this is 
to prevent picking invisible artists (as they are clipped).
While others may have better advice, mine is to use "button pressed" event 
directly.

lab = ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
def picklabel(artsits, mouseevent):
for a in artsits:
a.pick(mouseevent)
from functools import partial
b1 = fig.canvas.mpl_connect('button_press_event', partial(picklabel, [lab]))

Regards,

-JJ


On Fri, Jan 29, 2010 at 12:06 PM, Ben Axelrod 
mailto:baxel...@coroware.com>> wrote:
Picking text outside of the axes region seems to be broken in matplotlib 0.99.1 
and in the latest SVN.  This functionality used to work in version 0.98.3.  The 
example code pick_event_demo.py demonstrates the issue.  The "ylabel" in the 
red box is no longer pickable.  Is there a "clip_on" or similar setting on the 
picker that needs to be set now?  Below is a simplified version of 
"pick_event_demo.py" for reference.  I also added some text to the plot to make 
sure that text inside the axes region was still pickable.

Thanks,
-Ben

#!/usr/bin/env python
# simplified example code: pick_event_demo.py

from matplotlib.pyplot import figure, show
from matplotlib.lines import Line2D
from matplotlib.patches import Patch, Rectangle
from matplotlib.text import Text
from matplotlib.image import AxesImage
import numpy as npy
from numpy.random import rand

fig = figure()
ax1 = fig.add_subplot(111)
ax1.set_title('click on points, rectangles or text', picker=True)
ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
ax1.text(50, 0.5, "pick me", picker=True)
line, = ax1.plot(rand(100), 'o', picker=5)  # 5 points tolerance

def onpick1(event):
if isinstance(event.artist, Line2D):
thisline = event.artist
xdata = thisline.get_xdata()
ydata = thisline.get_ydata()
ind = event.ind
print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind))
elif isinstance(event.artist, Rectangle):
patch = event.artist
print 'onpick1 patch:', patch.get_path()
elif isinstance(event.artist, Text):
text = event.artist
print 'onpick1 text:', text.get_text()

fig.canvas.mpl_connect('pick_event', onpick1)

show()
#end code


Ben Axelrod
Robotics Engineer
(800) 641-2676 x737
[cid:875170521@01022010-3682]
www.coroware.com<http://www.coroware.com/>
www.corobot.net<http://www.corobot.net/>


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net<mailto:Matplotlib-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


<>--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Label picker broken?

2010-02-01 Thread Jae-Joon Lee
Current "pick" implementation  explicitly checks if the event is inside the
axes.
So, you cannot pick artists outside the axes area. This seems more like an
intended "feature" than a bug, but I may be wrong. And my guess is that this
is to prevent picking invisible artists (as they are clipped).
While others may have better advice, mine is to use "button pressed" event
directly.

lab = ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
def picklabel(artsits, mouseevent):
for a in artsits:
a.pick(mouseevent)
from functools import partial
b1 = fig.canvas.mpl_connect('button_press_event', partial(picklabel, [lab]))

Regards,

-JJ


On Fri, Jan 29, 2010 at 12:06 PM, Ben Axelrod  wrote:

>  Picking text outside of the axes region seems to be broken in matplotlib
> 0.99.1 and in the latest SVN.  This functionality used to work in version 
> 0.98.3.
> The example code pick_event_demo.py demonstrates the issue.  The "ylabel" in
> the red box is no longer pickable.  Is there a "clip_on" or similar setting
> on the picker that needs to be set now?  Below is a simplified version of
> "pick_event_demo.py" for reference.  I also added some text to the plot to
> make sure that text inside the axes region was still pickable.
>
> Thanks,
> -Ben
>
> #!/usr/bin/env python
> # simplified example code: pick_event_demo.py
>
> from matplotlib.pyplot import figure, show
> from matplotlib.lines import Line2D
> from matplotlib.patches import Patch, Rectangle
> from matplotlib.text import Text
> from matplotlib.image import AxesImage
> import numpy as npy
> from numpy.random import rand
>
> fig = figure()
> ax1 = fig.add_subplot(111)
> ax1.set_title('click on points, rectangles or text', picker=True)
> ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
> ax1.text(50, 0.5, "pick me", picker=True)
> line, = ax1.plot(rand(100), 'o', picker=5)  # 5 points tolerance
>
> def onpick1(event):
> if isinstance(event.artist, Line2D):
> thisline = event.artist
> xdata = thisline.get_xdata()
> ydata = thisline.get_ydata()
> ind = event.ind
> print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata,
> ind))
> elif isinstance(event.artist, Rectangle):
> patch = event.artist
> print 'onpick1 patch:', patch.get_path()
> elif isinstance(event.artist, Text):
> text = event.artist
> print 'onpick1 text:', text.get_text()
>
> fig.canvas.mpl_connect('pick_event', onpick1)
>
> show()
> #end code
>
>
> *Ben Axelrod*
> Robotics Engineer
> (800) 641-2676 x737
>  www.coroware.com
> www.corobot.net
>
>
>
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
<>--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Label picker broken?

2010-01-29 Thread Ben Axelrod
Picking text outside of the axes region seems to be broken in matplotlib 0.99.1 
and in the latest SVN.  This functionality used to work in version 0.98.3.  The 
example code pick_event_demo.py demonstrates the issue.  The "ylabel" in the 
red box is no longer pickable.  Is there a "clip_on" or similar setting on the 
picker that needs to be set now?  Below is a simplified version of 
"pick_event_demo.py" for reference.  I also added some text to the plot to make 
sure that text inside the axes region was still pickable.

Thanks,
-Ben

#!/usr/bin/env python
# simplified example code: pick_event_demo.py

from matplotlib.pyplot import figure, show
from matplotlib.lines import Line2D
from matplotlib.patches import Patch, Rectangle
from matplotlib.text import Text
from matplotlib.image import AxesImage
import numpy as npy
from numpy.random import rand

fig = figure()
ax1 = fig.add_subplot(111)
ax1.set_title('click on points, rectangles or text', picker=True)
ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
ax1.text(50, 0.5, "pick me", picker=True)
line, = ax1.plot(rand(100), 'o', picker=5)  # 5 points tolerance

def onpick1(event):
if isinstance(event.artist, Line2D):
thisline = event.artist
xdata = thisline.get_xdata()
ydata = thisline.get_ydata()
ind = event.ind
print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind))
elif isinstance(event.artist, Rectangle):
patch = event.artist
print 'onpick1 patch:', patch.get_path()
elif isinstance(event.artist, Text):
text = event.artist
print 'onpick1 text:', text.get_text()

fig.canvas.mpl_connect('pick_event', onpick1)

show()
#end code


Ben Axelrod
Robotics Engineer
(800) 641-2676 x737
[cid:109365016@29012010-0A93]
www.coroware.com
www.corobot.net

<>--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users