0.99.0-RC1 and the animation_blit_gtk2 example

Hello,

I’ve been playing with the animation_blit_gtk2 example (http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html

) and the latest version of matplotlib version 0.99.0-RC1.

I’ve modified the example so that it displays candlesticks
moving towards the lelf. The example is attached if anybody is interested.

In my example, I’m using 1 minute bars and therefore I would
like to shift the graph by 1 minute instead of a few pixels. Is there a way to convert
a time difference into pixels?

Thanks,

Christophe

animation_blit_gtk2-2.py (30.4 KB)

Hello,

I've been playing with the animation_blit_gtk2 example
(http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html

) and the latest version of matplotlib version 0.99.0-RC1.

I've modified the example so that it displays candlesticks moving towards
the lelf. The example is attached if anybody is interested.

In my example, I'm using 1 minute bars and therefore I would like to shift
the graph by 1 minute instead of a few pixels. Is there a way to convert a
time difference into pixels?

The "get_dx_data" method coverts a pixel offset to a data offset.
So, what you need is just to invert it.
This requires some knowledge of transformation, but I guess the code
is rather self-explanatory.

For example, something like below will work (sorry, I haven't
actually tested the code)

    def get_dx_pixel(self, dx_data):
        tp = self.ax.transData.transform_point
        x0, y0 = tp((0, 0))
        x1, y1 = tp((dx_data, 0))
        return (x1-x0)

Regards,

-JJ

···

On Tue, Aug 4, 2009 at 12:14 PM, Christophe Dupre<christophe.dupre@...2631...> wrote:

Thanks,

Christophe

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi JJ,

Thanks for that. It works fairly well, but I've noticed that the graph content (the candlesticks) move slightly faster than the x axis. I've added a sleep(0.1) statement to slow things down, and we can see that at the start the first bar is displayed at around 13:15 but by the times is gets to the left, the same bar is then displayed at about 13:00.

Do you have any suggestion on how to improve that?

Apart from that, shifting the graph is quite fast. On my machine, I get a frame rate of 30 FPS if I redraw both X and Y axis. The rate goes much higher ( greater than 100 FPS) if I don't redraw the axis.

Thanks,

Christophe

animation_blit_gtk2-2.py (30.4 KB)

···

-----Original Message-----
From: Jae-Joon Lee [mailto:lee.j.joon@…287…]
Sent: 05 August 2009 03:36
To: Christophe Dupre
Cc: matplotlib-users
Subject: Re: [Matplotlib-users] 0.99.0-RC1 and the animation_blit_gtk2 example

On Tue, Aug 4, 2009 at 12:14 PM, Christophe Dupre<christophe.dupre@...2631...> wrote:

Hello,

I've been playing with the animation_blit_gtk2 example
(http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html

) and the latest version of matplotlib version 0.99.0-RC1.

I've modified the example so that it displays candlesticks moving towards
the lelf. The example is attached if anybody is interested.

In my example, I'm using 1 minute bars and therefore I would like to shift
the graph by 1 minute instead of a few pixels. Is there a way to convert a
time difference into pixels?

The "get_dx_data" method coverts a pixel offset to a data offset.
So, what you need is just to invert it.
This requires some knowledge of transformation, but I guess the code
is rather self-explanatory.

For example, something like below will work (sorry, I haven't
actually tested the code)

    def get_dx_pixel(self, dx_data):
        tp = self.ax.transData.transform_point
        x0, y0 = tp((0, 0))
        x1, y1 = tp((dx_data, 0))
        return (x1-x0)

Regards,

-JJ

Thanks,

Christophe

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.43/2281 - Release Date: 08/04/09 05:57:00

Christophe,

Unfortunately, the background is always shifted by integer pixel. So,
shift in data and shift in pixel have some offset and what you see is
the accumulation of this offset.
And you have to manage the pixel and and data coordinates in sync.

For example, you may try to keep the original transform and calculate
the pixel shift in this
coordinate. This would work if you're not worried about the overflow.

The attached example solve this with different approach. However,
dx_data in this approach is not constant but fluctuate, although its
mean value should be one minute.

Regards,

-JJ

animation_blit_gtk2-3.py (30.5 KB)

···

On Wed, Aug 5, 2009 at 7:48 AM, Christophe Dupre<christophe.dupre@...2631...> wrote:

Hi JJ,

Thanks for that. It works fairly well, but I've noticed that the graph content (the candlesticks) move slightly faster than the x axis. I've added a sleep(0.1) statement to slow things down, and we can see that at the start the first bar is displayed at around 13:15 but by the times is gets to the left, the same bar is then displayed at about 13:00.

Do you have any suggestion on how to improve that?

Apart from that, shifting the graph is quite fast. On my machine, I get a frame rate of 30 FPS if I redraw both X and Y axis. The rate goes much higher ( greater than 100 FPS) if I don't redraw the axis.

Thanks,

Christophe

-----Original Message-----
From: Jae-Joon Lee [mailto:lee.j.joon@…287…]
Sent: 05 August 2009 03:36
To: Christophe Dupre
Cc: matplotlib-users
Subject: Re: [Matplotlib-users] 0.99.0-RC1 and the animation_blit_gtk2 example

On Tue, Aug 4, 2009 at 12:14 PM, Christophe > Dupre<christophe.dupre@...2631...> wrote:

Hello,

I've been playing with the animation_blit_gtk2 example
(http://matplotlib.sourceforge.net/examples/animation/animation_blit_gtk2.html

) and the latest version of matplotlib version 0.99.0-RC1.

I've modified the example so that it displays candlesticks moving towards
the lelf. The example is attached if anybody is interested.

In my example, I'm using 1 minute bars and therefore I would like to shift
the graph by 1 minute instead of a few pixels. Is there a way to convert a
time difference into pixels?

The "get_dx_data" method coverts a pixel offset to a data offset.
So, what you need is just to invert it.
This requires some knowledge of transformation, but I guess the code
is rather self-explanatory.

For example, something like below will work (sorry, I haven't
actually tested the code)

def get_dx_pixel(self, dx_data):
tp = self.ax.transData.transform_point
x0, y0 = tp((0, 0))
x1, y1 = tp((dx_data, 0))
return (x1-x0)

Regards,

-JJ

Thanks,

Christophe

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.43/2281 - Release Date: 08/04/09 05:57:00

Thanks JJ, this works fairly well.

I was wondering if the following would also be possible: at start up, draw all the minute bars in an invisible background, and on each update only display a subset of the background.

Regards,

Christophe

···

-----Original Message-----
From: Jae-Joon Lee [mailto:lee.j.joon@…287…]
Sent: 06 August 2009 17:01
To: Christophe Dupre
Cc: matplotlib-users
Subject: Re: [Matplotlib-users] 0.99.0-RC1 and the animation_blit_gtk2 example

Christophe,

Unfortunately, the background is always shifted by integer pixel. So, shift in data and shift in pixel have some offset and what you see is the accumulation of this offset.
And you have to manage the pixel and and data coordinates in sync.

For example, you may try to keep the original transform and calculate the pixel shift in this coordinate. This would work if you're not worried about the overflow.

The attached example solve this with different approach. However, dx_data in this approach is not constant but fluctuate, although its mean value should be one minute.

Regards,

-JJ

On Wed, Aug 5, 2009 at 7:48 AM, Christophe Dupre<christophe.dupre@...2631...> wrote:

Hi JJ,

Thanks for that. It works fairly well, but I've noticed that the graph content (the candlesticks) move slightly faster than the x axis. I've added a sleep(0.1) statement to slow things down, and we can see that at the start the first bar is displayed at around 13:15 but by the times is gets to the left, the same bar is then displayed at about 13:00.

Do you have any suggestion on how to improve that?

Apart from that, shifting the graph is quite fast. On my machine, I get a frame rate of 30 FPS if I redraw both X and Y axis. The rate goes much higher ( greater than 100 FPS) if I don't redraw the axis.

Thanks,

Christophe

-----Original Message-----
From: Jae-Joon Lee [mailto:lee.j.joon@…287…]
Sent: 05 August 2009 03:36
To: Christophe Dupre
Cc: matplotlib-users
Subject: Re: [Matplotlib-users] 0.99.0-RC1 and the animation_blit_gtk2
example

On Tue, Aug 4, 2009 at 12:14 PM, Christophe > Dupre<christophe.dupre@...2631...> wrote:

Hello,

I've been playing with the animation_blit_gtk2 example
(http://matplotlib.sourceforge.net/examples/animation/animation_blit_
gtk2.html

) and the latest version of matplotlib version 0.99.0-RC1.

I've modified the example so that it displays candlesticks moving
towards the lelf. The example is attached if anybody is interested.

In my example, I'm using 1 minute bars and therefore I would like to
shift the graph by 1 minute instead of a few pixels. Is there a way
to convert a time difference into pixels?

The "get_dx_data" method coverts a pixel offset to a data offset.
So, what you need is just to invert it.
This requires some knowledge of transformation, but I guess the code
is rather self-explanatory.

For example, something like below will work (sorry, I haven't
actually tested the code)

def get_dx_pixel(self, dx_data):
tp = self.ax.transData.transform_point
x0, y0 = tp((0, 0))
x1, y1 = tp((dx_data, 0))
return (x1-x0)

Regards,

-JJ

Thanks,

Christophe

---------------------------------------------------------------------
--------- Let Crystal Reports handle the reporting - Free Crystal
Reports 2008 30-Day trial. Simplify your report design, integration
and deployment - and focus on what you do best, core application
coding. Discover what's new with Crystal Reports now.
http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.43/2281 - Release Date:
08/04/09 05:57:00

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.44/2283 - Release Date: 08/05/09 18:23:00