Re: [Matplotlib-users] pick event for images

2013-11-02 Thread Joe Kington
Hi Nils,


I'm glad you found it useful!

I'm certainly not opposed to seeing it integrated into matplotlib in the
long run.  At the moment, though, it's probably changing a bit too
quickly.  There's a lot of little things I'd like to add to it.

On the other hand, if it ever were integrated upstream, there's an
opportunity to clean things up quite a bit, as mpldatacursor currently has
quite a few workarounds for minor bugs in old versions of mpl and minor api
changes, etc.

Cheers!
-Joe


On Thu, Oct 31, 2013 at 8:00 AM, Nils Wagner nils...@googlemail.com wrote:

 Hi Joe,

 Just now I installed your package mpldatacursor and run the example
 image_example.py.
 Awesome !
 Is there a chance to integrate it into matplotlib ?

 Nils



 On Wed, Oct 30, 2013 at 5:58 PM, Joe Kington joferking...@gmail.comwrote:


 On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com wrote:
 
  Hi all,
 
  How can I retrieve the corresponding color value in percent, when I
 click on the image ?
 

 You have to jump through a couple of hoops.

 Have a look at the _coords2index function in pick_info.py for
 mpldatacursor.
 https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py

 Also, mpldatacursor might be useful for what you're doing. Not to plug my
 own project too much, but it does exactly this, among other things.

 Hope that helps!
 -Joe

  fig = plt.figure()
  ax  = fig.add_subplot(111)
  cax = ax.imshow(col[:,::2],
 interpolation='nearest',extent=[0.5,20.5,0.5,2
  0.5],alpha=1,picker=5)
 
  fig.canvas.mpl_connect('pick_event', onpick)
 
  def onpick(event):
   ...
 
 
  Nils
 
 
 
 --
  Android is increasing in popularity, but the open development platform
 that
  developers love is also attractive to malware creators. Download this
 white
  paper to learn more about secure code signing practices that can help
 keep
  Android apps secure.
 
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 



--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event for images

2013-11-02 Thread Joe Kington
Hi Daniele,

First off, the FSF uses and endorses a number of non GPL licenses.  They
reccomend the Apache license over MIT-style licenses for permissive cases
due to patent issues, but they don't require it.  In fact, even the GNU
project has several X11 (the FSF's name for the MIT license) licensed
projects (e.g. Off the top of my head, I know ncurses is both an official
GNU project and is X11-licensed.).

However, I'm glad you brought this up.  I haven't actually filled out a
copyright transfer form to the FSF.  I intended to at one point, but never
did and didn't think about the copyright assignment in the license header
very much. Not doing so, and leaving copyright in the name of any potential
contributors actually makes things quite a bit simpler.

At any rate, it's certainly something I should clarify.

Thanks!
-Joe


On Sat, Nov 2, 2013 at 11:55 AM, Daniele Nicolodi dani...@grinta.netwrote:

 Hello Joe,

 I accidentally had a look at the source file you linked to and I found
 the copyright and license terms quite strange.  Are you really
 transferring copyright for your work to the Free Software Foundation
 which is releasing it under the MIT license?  I find very strange that
 the FSF is using a license other than the (L)GPL.  Does it also mean
 that who wants to contribute to your project must sign a copyright
 assignment to the FSF?

 I'm puzzled.

 Best,
 Daniele


 On 30/10/2013 17:58, Joe Kington wrote:
 
  On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com
  mailto:nils...@googlemail.com wrote:
 
  Hi all,
 
  How can I retrieve the corresponding color value in percent, when I
  click on the image ?
 
 
  You have to jump through a couple of hoops.
 
  Have a look at the _coords2index function in pick_info.py for
  mpldatacursor.
 
 https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py
 
  Also, mpldatacursor might be useful for what you're doing. Not to plug
  my own project too much, but it does exactly this, among other things.
 
  Hope that helps!
  -Joe
 
  fig = plt.figure()
  ax  = fig.add_subplot(111)
  cax = ax.imshow(col[:,::2],
 interpolation='nearest',extent=[0.5,20.5,0.5,2
  0.5],alpha=1,picker=5)
 
  fig.canvas.mpl_connect('pick_event', onpick)
 
  def onpick(event):
   ...
 
 
  Nils
 
 
 
 
 --
  Android is increasing in popularity, but the open development platform
  that
  developers love is also attractive to malware creators. Download this
  white
  paper to learn more about secure code signing practices that can help
 keep
  Android apps secure.
 
 
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  mailto:Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 
 --
  Android is increasing in popularity, but the open development platform
 that
  developers love is also attractive to malware creators. Download this
 white
  paper to learn more about secure code signing practices that can help
 keep
  Android apps secure.
 
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
 
 
 
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 



 --
 Android is increasing in popularity, but the open development platform that
 developers love is also attractive to malware creators. Download this white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event for images

2013-11-02 Thread Daniele Nicolodi
On 02/11/2013 19:07, Joe Kington wrote:
 Hi Daniele,
 
 First off, the FSF uses and endorses a number of non GPL licenses.  They
 reccomend the Apache license over MIT-style licenses for permissive
 cases due to patent issues, but they don't require it.  In fact, even
 the GNU project has several X11 (the FSF's name for the MIT license)
 licensed projects (e.g. Off the top of my head, I know ncurses is both
 an official GNU project and is X11-licensed.).

Thank for the info.  I knew that the FSF endorses a number of different
licenses, but I was under the impression that the only projects for
which copyright transfer was in place were under the GPL or LGPL
license.  I don't know if it makes much sense for other, more
permissive, licenses.

 However, I'm glad you brought this up.  I haven't actually filled out a
 copyright transfer form to the FSF.  I intended to at one point, but
 never did and didn't think about the copyright assignment in the license
 header very much. Not doing so, and leaving copyright in the name of any
 potential contributors actually makes things quite a bit simpler.

Indeed. I believe going the burden of copyright transfer makes sense
only for major projects under copyleft licenses.

Cheers,
Daniele


--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event for images

2013-10-31 Thread Nils Wagner
Hi Joe,

Just now I installed your package mpldatacursor and run the example
image_example.py.
Awesome !
Is there a chance to integrate it into matplotlib ?

Nils



On Wed, Oct 30, 2013 at 5:58 PM, Joe Kington joferking...@gmail.com wrote:


 On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com wrote:
 
  Hi all,
 
  How can I retrieve the corresponding color value in percent, when I
 click on the image ?
 

 You have to jump through a couple of hoops.

 Have a look at the _coords2index function in pick_info.py for
 mpldatacursor.
 https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py

 Also, mpldatacursor might be useful for what you're doing. Not to plug my
 own project too much, but it does exactly this, among other things.

 Hope that helps!
 -Joe

  fig = plt.figure()
  ax  = fig.add_subplot(111)
  cax = ax.imshow(col[:,::2],
 interpolation='nearest',extent=[0.5,20.5,0.5,2
  0.5],alpha=1,picker=5)
 
  fig.canvas.mpl_connect('pick_event', onpick)
 
  def onpick(event):
   ...
 
 
  Nils
 
 
 
 --
  Android is increasing in popularity, but the open development platform
 that
  developers love is also attractive to malware creators. Download this
 white
  paper to learn more about secure code signing practices that can help
 keep
  Android apps secure.
 
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 


--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pick event for images

2013-10-30 Thread Nils Wagner
Hi all,

How can I retrieve the corresponding color value in percent, when I click
on the image ?

fig = plt.figure()
ax  = fig.add_subplot(111)
cax = ax.imshow(col[:,::2], interpolation='nearest',extent=[0.5,20.5,0.5,2
0.5],alpha=1,picker=5)

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

def onpick(event):
 ...


Nils
attachment: image.png--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event for images

2013-10-30 Thread Joe Kington
On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com wrote:

 Hi all,

 How can I retrieve the corresponding color value in percent, when I
click on the image ?


You have to jump through a couple of hoops.

Have a look at the _coords2index function in pick_info.py for
mpldatacursor.
https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py

Also, mpldatacursor might be useful for what you're doing. Not to plug my
own project too much, but it does exactly this, among other things.

Hope that helps!
-Joe

 fig = plt.figure()
 ax  = fig.add_subplot(111)
 cax = ax.imshow(col[:,::2], interpolation='nearest',extent=[0.5,20.5,0.5,2
 0.5],alpha=1,picker=5)

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

 def onpick(event):
  ...


 Nils



--
 Android is increasing in popularity, but the open development platform
that
 developers love is also attractive to malware creators. Download this
white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.

http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Pick event after using Zoom to rectangle

2013-10-29 Thread Nils Wagner
Hi all,

How can I use a pick event when I have used Zoom to rectangle before ?

Nils
--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pick event after using Zoom to rectangle

2013-10-29 Thread Joe Kington
If you're asking how to do it interactively, just click on the zoom button
again, and you should be able to fire pick events by clicking again.

Hope that helps!
-Joe
On Oct 29, 2013 4:58 AM, Nils Wagner nils...@googlemail.com wrote:

 Hi all,

 How can I use a pick event when I have used Zoom to rectangle before ?

 Nils



 --
 Android is increasing in popularity, but the open development platform that
 developers love is also attractive to malware creators. Download this white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pick event after using Zoom to rectangle

2013-10-29 Thread Nils Wagner
Thank you very much !


On Tue, Oct 29, 2013 at 3:16 PM, Joe Kington joferking...@gmail.com wrote:

 If you're asking how to do it interactively, just click on the zoom button
 again, and you should be able to fire pick events by clicking again.

 Hope that helps!
 -Joe
 On Oct 29, 2013 4:58 AM, Nils Wagner nils...@googlemail.com wrote:

 Hi all,

 How can I use a pick event when I have used Zoom to rectangle before ?

 Nils



 --
 Android is increasing in popularity, but the open development platform
 that
 developers love is also attractive to malware creators. Download this
 white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.

 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Pick Event - twinx

2012-11-03 Thread Arek Kedzior
Hi all,
I am aware when using overlapping axes twinx I can only pick the objects in the 
active axes.
I would like to pick objects (lines) in both axes.
Does anyone have the workaround to this problem

Regards,
Arek 

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pick event

2012-05-13 Thread Jerzy Karczmarczuk
(13/05/2012 02:52), Arek Kędzior:
 What I am trying is to plot multiple discontinuous lines.
 I know that this approach does not work very well. How about
 using LineCollection.
 Put all curves into line collection
 Use Pick event to get line segment (what function to use ?)
 Once I have line segment, get xdata, ydata corresponding to line 
 segment (what function to use ?)
Why don't you use:

picker=myTest

in your ax.plot, where

def myTest(artist,mousevnt):
...
return (hit,kwdict)

performs any test you like? Again, this is called separately for every 
Artist belonging to the Usual Suspects, but you may control whether this 
is the first line found, then your program just computes the distance, 
or the second one, then it computes the distance, and discriminates 
between the two. The properties kwdict passed to your callback will 
permit to do the rest.
Or, perhaps, the first time the test doesn't do anything, and returns 
False, and the second time computes both distances, and finds the 
minimum. You have your private access to both lines anyway. The 
generalization to many lines should be straightforward.

Jerzy K.





--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pick event

2012-05-12 Thread Arek Kedzior
I am trying to use pick event.  See the simple script
below.  I am interested to find the shortest distance between pick
point (mouse coord.) and the  line at the discrete points only (points on
the curve from data)
What am I doing wrong ?
Regards,
Arek
 
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import math as math
 
# create figure and attach axes to it
fig = plt.figure(1)
ax = fig.add_subplot(111)
 
 
def getMinDistance(xmouse, ymouse, xList, yList):
    
    find shortest distance between mouse
coordinates and pick point
    point pick may be a list of points if
data is clouded
    Input
    xmouse - x coordinate of mouse (x - pick)
    ymouse - y coordinate of mouse (y - pick)
    xList  - xData from curve
    yList  - yData from curve
    Returns:
    dmin  - minimum distance
    index - index of data point in the xList
and yList
    
dmin  = math.sqrt((xList[0] -
xmouse)**2. + (yList[0]-ymouse)**2.)  
index = 0
    for idx in range(1,len(xList)):
    d =
math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.)
    if(d  dmin):
   
dmin = d
   
index = idx
return dmin, index
 
def showMarker(x, y, color):
    
    draw marker at loction x, y with color
    
    # draw marker
    markerOn, = ax.plot(x, y, 'o', color =
color) 

def OnPick(event):
    
    pick event
    
    print ''
    mouseEvent = event.mouseevent
    # get pick coord
    xmouse, ymouse = mouseEvent.xdata,
mouseEvent.ydata
    # get the artist
    lineObj = event.artist 
print lineObj
if not isinstance(lineObj, Line2D):
    return 
ind = event.ind 
# check if indexes exist of the pick
object
    N = len(ind)
    if not N:
    return
    # get curve picked data
    Xdata, Ydata = lineObj.get_data()
    color = lineObj.get_color()
xLi = np.take(Xdata, ind)
    yLi = np.take(Ydata, ind)
    dmin, index = getMinDistance(xmouse,
ymouse, xLi, yLi)
    
xP = xLi[index]
    yP = yLi[index]
    
xStr = '%.4g' % xP
    yStr = '%.4g' % yP
    txt = 'X = ' + xStr + ' ;  ' + 'Y =
' + yStr
    print txt
    # show marker
    showMarker(xP, yP, color)
    # redraw to show marker
    fig.canvas.draw()
    
# connect to pick event    
fig.canvas.mpl_connect('pick_event',OnPick)
 
# generate data for display
x = np.arange(-4,4,0.1)  # x-
coord
y2 = x**2 + 5.0 
# y coord of first curve
y  = 2*x +
4.0  
# y coord of the second curve
# create the list of x and y data 
xList = [x,
x]   
yList = [y, y2]
objList = [] # store draw lines
(artists)
# display 2 curves 
for idx in range(len(xList)):
    obj, = ax.plot(xList[idx], yList[idx],
picker = 5)
    objList.append(obj)
 
# display plot
plt.show(1)--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event

2012-05-12 Thread Jerzy Karczmarczuk

Arek Ke;dzior:

I am trying to use pick event.

...

What am I doing wrong ?

Wrong with WHAT?
What do you expect?

Jerzy Karczmarczuk

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event

2012-05-12 Thread Benjamin Root
On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote:

  Arek Kędzior:

   I am trying to use pick event.

 ...

   What am I doing wrong ?

 Wrong with WHAT?
 What do you expect?

 Jerzy Karczmarczuk



Arek.

Could you provide a little more detail about your issue?

Cheers!
Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pick event

2012-05-12 Thread Arek Kedzior
If you pick one of the curves in the close location to tangancy area, the 
OnPick function will be ececuted twice (2 curves) and will display 2 markers. I 
want to find the shortest distance from the pick location (mouse coord.) to a 
discrete point on the curve and draw marker on the curve at this location (only 
one).  See the line with print lineObj 

 


 From: matplotlib-users-requ...@lists.sourceforge.net 
matplotlib-users-requ...@lists.sourceforge.net
To: matplotlib-users@lists.sourceforge.net 
Sent: Saturday, May 12, 2012 10:59 AM
Subject: Matplotlib-users Digest, Vol 72, Issue 10
  
Send Matplotlib-users mailing list submissions to
    matplotlib-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users
or, via email, send a message with subject or body 'help' to
    matplotlib-users-requ...@lists.sourceforge.net

You can reach the person managing the list at
    matplotlib-users-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than Re: Contents of Matplotlib-users digest...


Today's Topics:

   1. pick event (Arek Kedzior)
   2. Re: pick event (Jerzy Karczmarczuk)
   3. Re: pick event (Benjamin Root)


--

Message: 1
Date: Sat, 12 May 2012 06:07:37 -0700 (PDT)
From: Arek Kedzior akedz...@yahoo.com
Subject: [Matplotlib-users] pick event
To: matplotlib-users@lists.sourceforge.net
    matplotlib-users@lists.sourceforge.net
Message-ID:
    1336828057.20499.yahoomail...@web140317.mail.bf1.yahoo.com
Content-Type: text/plain; charset=iso-8859-1

I am trying to use pick event.? See the simple script
below.? I am interested to find the shortest distance between pick
point (mouse coord.) and the ?line at the discrete points only (points on
the curve from data)
What am I doing wrong ?
Regards,
Arek
?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import math as math
?
# create figure and attach axes to it
fig = plt.figure(1)
ax = fig.add_subplot(111)
?
?
def getMinDistance(xmouse, ymouse, xList, yList):
??? 
??? find shortest distance between mouse
coordinates and pick point
??? point pick may be a list of points if
data is clouded
??? Input
??? xmouse - x coordinate of mouse (x - pick)
??? ymouse - y coordinate of mouse (y - pick)
??? xList? - xData from curve
??? yList? - yData from curve
??? Returns:
??? dmin? - minimum distance
??? index - index of data point in the xList
and yList
??? 
dmin? = math.sqrt((xList[0] -
xmouse)**2. + (yList[0]-ymouse)**2.)? 
index = 0
??? for idx in range(1,len(xList)):
??? d =
math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.)
??? if(d  dmin):
???
dmin = d
???
index = idx
return dmin, index
?
def showMarker(x, y, color):
??? 
??? draw marker at loction x, y with color
??? 
??? # draw marker
??? markerOn, = ax.plot(x, y, 'o', color =
color) 

def OnPick(event):
??? 
??? pick event
??? 
??? print ''
??? mouseEvent = event.mouseevent
??? # get pick coord
??? xmouse, ymouse = mouseEvent.xdata,
mouseEvent.ydata
??? # get the artist
??? lineObj = event.artist 
print lineObj
if not isinstance(lineObj, Line2D):
??? return 
ind = event.ind 
# check if indexes exist of the pick
object
??? N = len(ind)
??? if not N:
??? return
??? # get curve picked data
??? Xdata, Ydata = lineObj.get_data()
??? color = lineObj.get_color()
xLi = np.take(Xdata, ind)
??? yLi = np.take(Ydata, ind)
??? dmin, index = getMinDistance(xmouse,
ymouse, xLi, yLi)
??? 
xP = xLi[index]
??? yP = yLi[index]
??? 
xStr = '%.4g' % xP
??? yStr = '%.4g' % yP
??? txt = 'X = ' + xStr + ' ;? ' + 'Y =
' + yStr
??? print txt
??? # show marker
??? showMarker(xP, yP, color)
??? # redraw to show marker
??? fig.canvas.draw()
??? 
# connect to pick event??? 
fig.canvas.mpl_connect('pick_event',OnPick)
?
# generate data for display
x = np.arange(-4,4,0.1)? # x-
coord
y2 = x**2 + 5.0?
# y coord of first curve
y? = 2*x +
4.0??
# y coord of the second curve
# create the list of x and y data 
xList = [x,
x]?? 
yList = [y, y2]
objList = [] # store draw lines
(artists)
# display 2 curves 
for idx in range(len(xList)):
??? obj, = ax.plot(xList[idx], yList[idx],
picker = 5)
??? objList.append(obj)
?
# display plot
plt.show(1)
-- next part --
An HTML attachment was scrubbed...

--

Message: 2
Date: Sat, 12 May 2012 16:44:16 +0200
From: Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr
Subject: Re: [Matplotlib-users] pick event
To: matplotlib-users@lists.sourceforge.net
Message-ID: 4fae7740.7070...@unicaen.fr
Content-Type: text/plain; charset=iso-8859-1

Arek Ke;dzior:
 I am trying to use pick event.
...
 What am I doing wrong ?
Wrong with WHAT?
What do

Re: [Matplotlib-users] pick event

2012-05-12 Thread Jerzy Karczmarczuk

Arek Ke;dzior:
If you pick one of the curves in the close location to tangancy area, 
the OnPick function will be executed twice (2 curves) and will display 
2 markers. I want to find the shortest distance from the pick location 
(mouse coord.) to a discrete point on the curve and draw marker on the 
curve at this location (only one). See the line with print lineObj

Ok, now I -- perhaps -- understand.
This is a speculation...

Your approach cannot work, since the low level event handling issues TWO 
pick events, one for each curve. Everything works very well, your 
program finds the appropriate point ... on both curves, separately.


I suggest that you try to react to lower level mouse events. Look into 
the Pick code within the Artist class. The system tries to pick all the 
children, and here - I believe - resides your problem. You should 
perhaps discriminate the picked target at this point.


Jerzy Karczmarczuk

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pick event

2012-05-12 Thread Arek Kedzior
What I am trying is to plot multiple discontinuous lines.
I know that this approach does not work very well.  How about
using LineCollection.
Put all curves into line collection
Use Pick event to get line segment (what function to use ?)
Once I have line segment, get xdata, ydata corresponding to line segment (what 
function to use ?)
 
I tied this approach as well
Put all data points into numpy.array and each curve was separated by numpy.nan
It worked but I was getting run-time warning in distance calculations.
Any suggestions how to ?
Regards,
Arek
 


 From: matplotlib-users-requ...@lists.sourceforge.net 
matplotlib-users-requ...@lists.sourceforge.net
To: matplotlib-users@lists.sourceforge.net 
Sent: Saturday, May 12, 2012 1:12 PM
Subject: Matplotlib-users Digest, Vol 72, Issue 11
  
Send Matplotlib-users mailing list submissions to
    matplotlib-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users
or, via email, send a message with subject or body 'help' to
    matplotlib-users-requ...@lists.sourceforge.net

You can reach the person managing the list at
    matplotlib-users-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than Re: Contents of Matplotlib-users digest...


Today's Topics:

   1. Re: Matplotlib-users Digest, Vol 72, Issue 10 (Arek Kedzior)
   2. Re: pick event (Arek Kedzior)


--

Message: 1
Date: Sat, 12 May 2012 09:35:59 -0700 (PDT)
From: Arek Kedzior akedz...@yahoo.com
Subject: Re: [Matplotlib-users] Matplotlib-users Digest, Vol 72, Issue
    10
To: matplotlib-users@lists.sourceforge.net
    matplotlib-users@lists.sourceforge.net
Message-ID:
    1336840559.33998.yahoomail...@web140304.mail.bf1.yahoo.com
Content-Type: text/plain; charset=iso-8859-1

If you pick one of the curves in the close location to tangancy area, the 
OnPick function?will be?ececuted twice (2 curves) and will display 2 markers. I 
want to find the shortest distance from the pick location (mouse coord.) to a 
discrete point on the curve and?draw?marker on the curve at this location (only 
one).? See the line with print lineObj 




From: matplotlib-users-requ...@lists.sourceforge.net 
matplotlib-users-requ...@lists.sourceforge.net
To: matplotlib-users@lists.sourceforge.net 
Sent: Saturday, May 12, 2012 10:59 AM
Subject: Matplotlib-users Digest, Vol 72, Issue 10
  
Send Matplotlib-users mailing list submissions to
??? matplotlib-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
??? https://lists.sourceforge.net/lists/listinfo/matplotlib-users
or, via email, send a message with subject or body 'help' to
??? matplotlib-users-requ...@lists.sourceforge.net

You can reach the person managing the list at
??? matplotlib-users-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than Re: Contents of Matplotlib-users digest...


Today's Topics:

?  1. pick event (Arek Kedzior)
?  2. Re: pick event (Jerzy Karczmarczuk)
?  3. Re: pick event (Benjamin Root)


--

Message: 1
Date: Sat, 12 May 2012 06:07:37 -0700 (PDT)
From: Arek Kedzior akedz...@yahoo.com
Subject: [Matplotlib-users] pick event
To: matplotlib-users@lists.sourceforge.net
??? matplotlib-users@lists.sourceforge.net
Message-ID:
??? 1336828057.20499.yahoomail...@web140317.mail.bf1.yahoo.com
Content-Type: text/plain; charset=iso-8859-1

I am trying to use pick event.? See the simple script
below.? I am interested to find the shortest distance between pick
point (mouse coord.) and the ?line at the discrete points only (points on
the curve from data)
What am I doing wrong ?
Regards,
Arek
?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import math as math
?
# create figure and attach axes to it
fig = plt.figure(1)
ax = fig.add_subplot(111)
?
?
def getMinDistance(xmouse, ymouse, xList, yList):
??? 
??? find shortest distance between mouse
coordinates and pick point
??? point pick may be a list of points if
data is clouded
??? Input
??? xmouse - x coordinate of mouse (x - pick)
??? ymouse - y coordinate of mouse (y - pick)
??? xList? - xData from curve
??? yList? - yData from curve
??? Returns:
??? dmin? - minimum distance
??? index - index of data point in the xList
and yList
??? 
dmin? = math.sqrt((xList[0] -
xmouse)**2. + (yList[0]-ymouse)**2.)? 
index = 0
??? for idx in range(1,len(xList)):
??? d =
math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.)
??? if(d  dmin):
???
dmin = d
???
index = idx
return dmin, index
?
def showMarker(x, y, color):
??? 
??? draw marker at loction x, y with color
??? 
??? # draw marker
??? markerOn, = ax.plot(x, y, 'o', color =
color

[Matplotlib-users] Pick event and annotate

2010-02-10 Thread Nils Wagner
Hi all,

How can I combine onpick events with annotate ?
Any pointer would be appreciated.

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('click on points')

line, = ax.plot(np.random.rand(100), 'o', picker=5)  # 5 
points tolerance

def onpick(event):
 thisline = event.artist
 xdata = thisline.get_xdata()
 ydata = thisline.get_ydata()
 ind = event.ind
 print 'onpick points:', zip(xdata[ind], ydata[ind]), 
ind
 ax.annotate('Test',xy=(ind, 
ydata[ind]),horizontalalignment='left',verticalalignment='top')
#   ax.redraw_in_frame()

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

plt.show()



Thanks in advance.

  Nils

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pick event and annotate

2010-02-10 Thread John Hunter
On Wed, Feb 10, 2010 at 4:43 AM, Nils Wagner
nwag...@iam.uni-stuttgart.de wrote:
 Hi all,

 How can I combine onpick events with annotate ?
 Any pointer would be appreciated.

 import numpy as np
 import matplotlib.pyplot as plt

 fig = plt.figure()
 ax = fig.add_subplot(111)
 ax.set_title('click on points')

 line, = ax.plot(np.random.rand(100), 'o', picker=5)  # 5
 points tolerance

 def onpick(event):
     thisline = event.artist
     xdata = thisline.get_xdata()
     ydata = thisline.get_ydata()
     ind = event.ind
     print 'onpick points:', zip(xdata[ind], ydata[ind]),
 ind
     ax.annotate('Test',xy=(ind,
 ydata[ind]),horizontalalignment='left',verticalalignment='top')
 #   ax.redraw_in_frame()


You need to call fig.canvas.draw() at the end of onpick.

JDH


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

 plt.show()



 Thanks in advance.

                          Nils

 --
 SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users