hoe to update a plot

Hi
I am using gtk and displaying a plot in a FigureCanvas. In response to an event, I want to update the plot with new data.

e.g.
self.fig = Figure(figsize=(5,5), dpi=100)
self.ax = fig.add_subplot(111)
ax.plot(data[0,0:,0],

canvas = FigureCanvas(fig)
canvas.set_size_request(500,500)

def on_some_signal(self,widget):
???

I’ve tried a number of different things. How do you do this?

Mathew

I may be wrong here, but isn't it:

def on_some_signal(self,widget):
    ax.plot(yournewdata)
    canvas.draw()

Che

···

On Tue, Feb 23, 2010 at 7:00 PM, Mathew Yeates <mat.yeates@...287...> wrote:

Hi
I am using gtk and displaying a plot in a FigureCanvas. In response to an
event, I want to update the plot with new data.

e.g.
self.fig = Figure(figsize=(5,5), dpi=100)
self.ax = fig.add_subplot(111)
ax.plot(data[0,0:,0],

canvas = FigureCanvas(fig)
canvas.set_size_request(500,500)

def on_some_signal(self,widget):
???

I've tried a number of different things. How do you do this?

C M wrote:

  

Hi
I am using gtk and displaying a plot in a FigureCanvas. In response to an
event, I want to update the plot with new data.

e.g.
self.fig = Figure(figsize=(5,5), dpi=100)
self.ax = fig.add_subplot(111)
ax.plot(data[0,0:,0],

canvas = FigureCanvas(fig)
canvas.set_size_request(500,500)

def on_some_signal(self,widget):
    ???

I've tried a number of different things. How do you do this?
    
I may be wrong here, but isn't it:

def on_some_signal(self,widget):
    ax.plot(yournewdata)
    canvas.draw()

Che

I also may be wrong.

I thought ax.plot(..) would redraw everything (ticks, labels, etc) to do with the plot.

I've been using set_data as I thought it was meant to be quicker.
                self.cline[0].set_data(rX, myabs) # I have to make sure I use correct line
                         :: ::
                self.canvas.draw()

To just change the data associated with a specific line on plot.

I stored the lines on my graph in a list called cline, I captured the line at time of creating of the plot
                r = self.axis.plot( rX, myabs ,self.linestyle, color='b')
                self.cline.append( r[0] )

- Steve

···

On Tue, Feb 23, 2010 at 7:00 PM, Mathew Yeates <mat.yeates@...287...> wrote:

This looks correct. I went and look at the animation examples and they do something similar.

Thx

···

---------- Forwarded message ----------
From: Stephen George <steve_geo@…887…>

Date: Tue, Feb 23, 2010 at 6:28 PM
Subject: Re: [Matplotlib-users] hoe to update a plot
To: Matplotlib Users matplotlib-users@lists.sourceforge.net

C M wrote:

On Tue, Feb 23, 2010 at 7:00 PM, Mathew Yeates <mat.yeates@…287…> wrote:

Hi

I am using gtk and displaying a plot in a FigureCanvas. In response to an

event, I want to update the plot with new data.

e.g.

self.fig = Figure(figsize=(5,5), dpi=100)

self.ax = fig.add_subplot(111)

ax.plot(data[0,0:,0],

canvas = FigureCanvas(fig)

canvas.set_size_request(500,500)

def on_some_signal(self,widget):

?????

I also may be wrong.

I thought ax.plot(…) would redraw everything (ticks, labels, etc) to

do with the plot.

I’ve been using set_data as I thought it was meant to be quicker.

            self.cline[0].set_data(rX, myabs) # I have to make sure

I use correct line

                     ::          ::

            self.canvas.draw()

To just change the data associated with a specific line on plot.

I stored the lines on my graph in a list called cline, I captured the

line at time of creating of the plot

            r = self.axis.plot( rX, myabs ,self.linestyle, color='b')

            self.cline.append( r[0] )
  • Steve

Download Intel® Parallel Studio Eval

Try the new software tools for yourself. Speed compiling, find bugs

proactively, and fine-tune applications for parallel performance.

See why Intel Parallel Studio got high marks during beta.

http://p.sf.net/sfu/intel-sw-dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

On Tue, Feb 23, 2010 at 6:28 PM, Stephen George <steve_geo@…887…> wrote:

C M wrote:

On Tue, Feb 23, 2010 at 7:00 PM, Mathew Yeates <mat.yeates@…287…> wrote:

Hi

I am using gtk and displaying a plot in a FigureCanvas. In response to an

event, I want to update the plot with new data.

e.g.

self.fig = Figure(figsize=(5,5), dpi=100)

self.ax = fig.add_subplot(111)

ax.plot(data[0,0:,0],

canvas = FigureCanvas(fig)

canvas.set_size_request(500,500)

def on_some_signal(self,widget):

?????

I also may be wrong.

I thought ax.plot(…) would redraw everything (ticks, labels, etc) to

do with the plot.

I’ve been using set_data as I thought it was meant to be quicker.

            self.cline[0].set_data(rX, myabs) # I have to make sure

I use correct line

                     ::          ::

            self.canvas.draw()

To just change the data associated with a specific line on plot.

I stored the lines on my graph in a list called cline, I captured the

line at time of creating of the plot

            r = self.axis.plot( rX, myabs ,self.linestyle, color='b')

            self.cline.append( r[0] )
  • Steve

Download Intel® Parallel Studio Eval

Try the new software tools for yourself. Speed compiling, find bugs

proactively, and fine-tune applications for parallel performance.

See why Intel Parallel Studio got high marks during beta.

http://p.sf.net/sfu/intel-sw-dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users