SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Martin W. <mp...@bh...> - 2007年01月31日 21:12:36
Hi,
I'm using matplotlib in a GTK gui canvas with the GTKAgg backend. I'm 
connecting a mouse click 'button_press_event' to the click function. If 
I choose print event.x everything works fine. However I'm after the x 
value in terms of the x-axis not pixels. When I try print event.xdata I 
get an error message. Am I making a stupid mistake or is this a bug?
Thanks
Martin
 
 self.canvas.connect('button_press_event',self.click)
def click(self,widget,event):
 print 'you clicked', event.xdata, event.ydata
 #print 'you clicked', event.x, event.y
Traceback (most recent call last):
 File "./dangerplotpy", line 120, in click
 print 'you clicked', event.xdata, event.ydata
AttributeError: xdata
From: Martin W. <mp...@bh...> - 2007年02月05日 20:35:59
Hi,
I'm using matplotlib in a GTK gui canvas with the GTKAgg backend. I'm 
connecting a mouse click 'button_press_event' to the click function. If 
I choose print event.x everything works fine. However I'm after the x 
value in terms of the x-axis not pixels. When I try print event.xdata I 
get an error message. Am I making a stupid mistake or is this a bug?
Thanks
Martin
 
 self.canvas.connect('button_press_event',self.click)
def click(self,widget,event):
 print 'you clicked', event.xdata, event.ydata
 #print 'you clicked', event.x, event.y
Traceback (most recent call last):
 File "./dangerplotpy", line 120, in click
 print 'you clicked', event.xdata, event.ydata
AttributeError: xdata
From: John H. <jd...@gm...> - 2007年02月05日 21:45:22
On 2/5/07, Martin Wilson <mp...@bh...> wrote:
> Hi,
>
> I'm using matplotlib in a GTK gui canvas with the GTKAgg backend. I'm
> connecting a mouse click 'button_press_event' to the click function. If
> I choose print event.x everything works fine. However I'm after the x
> value in terms of the x-axis not pixels. When I try print event.xdata I
> get an error message. Am I making a stupid mistake or is this a bug?
> self.canvas.connect('button_press_event',self.click)
>
> def click(self,widget,event):
> print 'you clicked', event.xdata, event.ydata
> #print 'you clicked', event.x, event.y
>
>
> Traceback (most recent call last):
> File "./dangerplotpy", line 120, in click
> print 'you clicked', event.xdata, event.ydata
> AttributeError: xdata
The matplotlib GTKAgg canvas inherits from the gtk drawing area and
thus inherit's its connect method. You are connecting to GTK's event
handler, not matplotlib's. Use canvas.mpl_connect instead, as in this
example
from pylab import figure, show
fig = figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3])
def click(event):
 if event.inaxes is not None:
 print 'you clicked', event.xdata, event.ydata
fig.canvas.mpl_connect('button_press_event', click)
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /