Hi - I'm having problems - I don't get any line
> displayed on my screen. My code looks as follows
> (Init):
Make sure you are working with the line you think you are
Rather than doing this
self.axes.add_line(Line2D(,)
do this
self.line = Line2D(,
self.axes.add_line(self.line)
After you do this
line = self.data[source][0] # Retreive the line
check to make sure that id(line) and id(self.line) are the same.
Here is a simple example that binds events to adding line data.
Perhaps you can follow this (in wx you need to click on the figure
once before the keypress events will be processed)
from matplotlib.lines import Line2D
import matplotlib.numerix as nx
from pylab import figure, show
xdata =
ydata =
line = Line2D(xdata, ydata)
def add_data(event):
if event.key!='a': return
xdata.extend(nx.mlab.rand(10))
ydata.extend(nx.mlab.rand(10))
line.set_data(xdata, ydata)
fig.canvas.draw()
fig = figure()
ax = fig.add_subplot(111)
ax.add_line(line)
ax.set_title("Press 'a' to add more data")
fig.canvas.mpl_connect('key_press_event', add_data)
show()
Yes - this code works at home and at work (Linux/windows). I fail to see why
mine won't. I checked the id's - they're correct
···
-----Ursprüngliche Nachricht-----
Von: John Hunter [mailto:jdhunter@…4…]
Gesendet: Donnerstag, 25. August 2005 18:01
An: Schindler Benjamin
Cc: matplotlib-users@lists.sourceforge.net
Betreff: Re: [Matplotlib-users] Line2D and wx Backend
> Hi - I'm having problems - I don't get any line
> displayed on my screen. My code looks as follows
> (Init):
Make sure you are working with the line you think you are
Rather than doing this
self.axes.add_line(Line2D([],[])
do this
self.line = Line2D([],[]
self.axes.add_line(self.line)
After you do this
line = self.data[source][0] # Retreive the line
check to make sure that id(line) and id(self.line) are the same.
Here is a simple example that binds events to adding line data.
Perhaps you can follow this (in wx you need to click on the figure
once before the keypress events will be processed)
from matplotlib.lines import Line2D
import matplotlib.numerix as nx
from pylab import figure, show
xdata = []
ydata = []
line = Line2D(xdata, ydata)
def add_data(event):
if event.key!='a': return
xdata.extend(nx.mlab.rand(10))
ydata.extend(nx.mlab.rand(10))
line.set_data(xdata, ydata)
fig.canvas.draw()
fig = figure()
ax = fig.add_subplot(111)
ax.add_line(line)
ax.set_title("Press 'a' to add more data")
fig.canvas.mpl_connect('key_press_event', add_data)
show()