Hi Matplotlib users
I have an application where performance is critical and matplotlib is
the performance bottleneck. I am making a lot of figures using the
same basic setup of the figure. And from my profiling I can see that
this basic setup accounts for most of the CPU time. Let us say that I
make a given figure including some axes. My questions are:
1. Can I make a copy of this figure including axes (copy.deepcopy does
not work on Figure objects) and use the copy for plotting on?
2. And how? Should I use the frozen method somehow?
I did do something similar some years back. But at the time I removed
the stuff I had drawn on the figure. I would like to avoid this for
two reasons: 1) Thread safety, I must be able to draw figures in
several simultaneous threads and 2) I really had to go into some
low-level details in matplotlib (not a show-stopper, but for
maintenance reasons I would like to keep the code as clear as
possible).
Best regards,
Jesper
Jesper,
An experimental feature that will be available in the upcoming v1.2.0 release will be pickling support. It is marked as experimental as there are plenty of untested edge cases, but it should be a huge step in the right direction for the feature that you and many others have asked for. We certainly will welcome any and all feedback on what does and does not pickle well.
Cheers!
Ben Root
···
On Wed, Aug 15, 2012 at 5:40 AM, Jesper Larsen <jesper.webmail@…287…> wrote:
Hi Matplotlib users
I have an application where performance is critical and matplotlib is
the performance bottleneck. I am making a lot of figures using the
same basic setup of the figure. And from my profiling I can see that
this basic setup accounts for most of the CPU time. Let us say that I
make a given figure including some axes. My questions are:
- Can I make a copy of this figure including axes (copy.deepcopy does
not work on Figure objects) and use the copy for plotting on?
- And how? Should I use the frozen method somehow?
I did do something similar some years back. But at the time I removed
the stuff I had drawn on the figure. I would like to avoid this for
two reasons: 1) Thread safety, I must be able to draw figures in
several simultaneous threads and 2) I really had to go into some
low-level details in matplotlib (not a show-stopper, but for
maintenance reasons I would like to keep the code as clear as
possible).
Best regards,
Jesper
Some benchmarking would be useful as well. Pickling/unpickling can be very slow.
Eric
···
On 2012/09/09 8:50 AM, Benjamin Root wrote:
On Wed, Aug 15, 2012 at 5:40 AM, Jesper Larsen <jesper.webmail@...287... > <mailto:jesper.webmail@…287…>> wrote:
Hi Matplotlib users
I have an application where performance is critical and matplotlib is
the performance bottleneck. I am making a lot of figures using the
same basic setup of the figure. And from my profiling I can see that
this basic setup accounts for most of the CPU time. Let us say that I
make a given figure including some axes. My questions are:
1. Can I make a copy of this figure including axes (copy.deepcopy does
not work on Figure objects) and use the copy for plotting on?
2. And how? Should I use the frozen method somehow?
I did do something similar some years back. But at the time I removed
the stuff I had drawn on the figure. I would like to avoid this for
two reasons: 1) Thread safety, I must be able to draw figures in
several simultaneous threads and 2) I really had to go into some
low-level details in matplotlib (not a show-stopper, but for
maintenance reasons I would like to keep the code as clear as
possible).
Best regards,
Jesper
Jesper,
An experimental feature that will be available in the upcoming v1.2.0
release will be pickling support. It is marked as experimental as there
are plenty of untested edge cases, but it should be a huge step in the
right direction for the feature that you and many others have asked
for. We certainly will welcome any and all feedback on what does and
does not pickle well.
Cheers!
Ben Root