Adding grid to animation with blit

Hello,
I'm using blit to animate my plot, and I'd like to add a grid on it
but I failed at it.

What I do is:

1. prepare Figure, Axes, etc without plotting anything
2. save teh background with
     self.bg = self.canvas.copy_from_bbox(self.ax.bbox)

(on graph update)

3. restore background with
     self.canvas.restore_region(self.bg)
4. <line>.set_ydata(...)
5. self.ax.draw_artist(self.<line>)
6. self.canvas.blit(self.ax.bbox)

Now, I tried to place a "self.ax.grid(True)" in almost every possible
position, but never a grid came out :frowning:

What is the right approach to solve it? Thanks in advance

Regards,

···

--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

Without actual code, it is difficult to figure out what the real problem is.
Anyhow, did you check the below animation example?

http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk.html

In the example, the grid is static (i.e., not animated). If what you
want is to have the grid animated, then an explicit draw_artist call
is required (note that grid is drawn by axis).

Regards,

-JJ

···

On Sun, Jun 21, 2009 at 11:54 AM, Sandro Tosi<matrixhasu@...287...> wrote:

Hello,
I'm using blit to animate my plot, and I'd like to add a grid on it
but I failed at it.

What I do is:

1. prepare Figure, Axes, etc without plotting anything
2. save teh background with
self.bg = self.canvas.copy_from_bbox(self.ax.bbox)

(on graph update)

3. restore background with
self.canvas.restore_region(self.bg)
4. <line>.set_ydata(...)
5. self.ax.draw_artist(self.<line>)
6. self.canvas.blit(self.ax.bbox)

Now, I tried to place a "self.ax.grid(True)" in almost every possible
position, but never a grid came out :frowning:

What is the right approach to solve it? Thanks in advance

Regards,
--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Jae-Joon

Without actual code, it is difficult to figure out what the real problem is.

sorry I didn't attach a complete example but I would have to strip down a lot :slight_smile:

Anyhow, did you check the below animation example?

http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk.html

yes, but I didn't have the illumination; until now :slight_smile:

In the example, the grid is static (i.e., not animated). If what you

that's perfect, I do not want it to be anymated.

want is to have the grid animated, then an explicit draw_artist call
is required (note that grid is drawn by axis).

yeah, I want it to be only on Y (only horizonatal lines).

The solution is:

        self.ax = self.fig.add_subplot(111)
...
        self.ax.grid(True)
        self.canvas.draw() # <-- this was missing

        self.bg = self.canvas.copy_from_bbox(self.ax.bbox)

adding an explicit draw() call let the grid() be drawn and then the
result is what's expected.

Thanks a lot!

Cheers,

···

On Mon, Jun 22, 2009 at 21:14, Jae-Joon Lee<lee.j.joon@...287...> wrote:
--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi