[Matplotlib-users] Pick Event - twinx
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
[Matplotlib-users] (no subject)
http://comidaspopulares.com/yqwpcmdkr/344707.html-- 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] (no subject)
http://horit.com/yuaoqlcns/405279.html-- 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] (no subject)
http://akws.org/joelcmsqi/459113.html -- 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] (no subject)
http://kamiasek.kx.cz/daqowrtau/669669.html -- 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] (no subject)
http://makemeyounger.tv/ytnskwpvr/715341.html-- 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] (no subject)
http://reyesmagospamplona.com/tuluqmzrpc/780688.html-- 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] (no subject)
http://maison-cantury.com/rpsleyubzq/514834.html -- 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] (no subject)
http://paulaslominska.cba.pl/lnjysgcpta/395506.html-- 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
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] Matplotlib-users Digest, Vol 72, Issue 10
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
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
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