Re: [Matplotlib-users] matplotlib.rcParams(update) and parallel python

2011-10-18 Thread Martin Hoffmann
Thank you for the tip. I actually had played around with 
matplotlib.rcdefaults() before, but that didn't work. I tried now the 
using exactly the clear_state function you suggested. Since it still 
didn't work, I finally found out that I had a very similar problem with 
another module from which I determine axes, figure size and other 
things. So, thank you very much, that helped me a lot and now things 
work the way I want!

On Die 18 Okt 2011 04:45:27 CEST, John Hunter wrote:
> On Mon, Oct 17, 2011 at 2:57 PM, tinux  wrote:
>>
>> I have around 100 python files, that each create one figure using matplotlib.
>> Since I want to use all CPU cores, I basically did "for filename in files:
>> execfile(filename)" using a python script. However, this does not produce
>> the same output as running each file separately (for instance axes, figure
>> size are sometime wrong).
>> I _think_ I narrowed it down to this: In all files I need to do
>> "matplotlib.rcParams(update)". I guess that this influences the matplotlib
>> rc parameters and thus somehow values from some figures are used for others.
>>
>> So, my question is, how can I do something like
>> "matplotlib.rcParams(update)" so that it does not influence other scripts
>> that are run in parallel using 'execfile'? Or, how do I set rc parameters
>> for one specific script?
>>
>> BTW, I tried 'pp' and 'multiprocessing', same problem with both.
>
> The problem is that the rc params are module level in matplotlib so in
> a persistent process like ipython if one script modifies the rc
> params, subsequent files executed in the same process will be
> affected.  You can restore the rc params to their default state by
> doing before each call to execfile
>
> import matplotlib
> matplotlib.rc_file_defaults()
>
>
> We face the same issue in the "plot_directive" which we use when
> building the matplotlib documentation.  We define a function
> "clear_state" in
>
>   
> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/sphinxext/plot_directive.py#L484
>
> which closes all open figures, restore the rc defaults, and the
> updates the defaults to an rc dictionary of the parameters we want for
> each run.

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.rcParams(update) and parallel python

2011-10-17 Thread John Hunter
On Mon, Oct 17, 2011 at 2:57 PM, tinux  wrote:
>
> I have around 100 python files, that each create one figure using matplotlib.
> Since I want to use all CPU cores, I basically did "for filename in files:
> execfile(filename)" using a python script. However, this does not produce
> the same output as running each file separately (for instance axes, figure
> size are sometime wrong).
> I _think_ I narrowed it down to this: In all files I need to do
> "matplotlib.rcParams(update)". I guess that this influences the matplotlib
> rc parameters and thus somehow values from some figures are used for others.
>
> So, my question is, how can I do something like
> "matplotlib.rcParams(update)" so that it does not influence other scripts
> that are run in parallel using 'execfile'? Or, how do I set rc parameters
> for one specific script?
>
> BTW, I tried 'pp' and 'multiprocessing', same problem with both.

The problem is that the rc params are module level in matplotlib so in
a persistent process like ipython if one script modifies the rc
params, subsequent files executed in the same process will be
affected.  You can restore the rc params to their default state by
doing before each call to execfile

import matplotlib
matplotlib.rc_file_defaults()


We face the same issue in the "plot_directive" which we use when
building the matplotlib documentation.  We define a function
"clear_state" in

  
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/sphinxext/plot_directive.py#L484

which closes all open figures, restore the rc defaults, and the
updates the defaults to an rc dictionary of the parameters we want for
each run.

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib.rcParams(update) and parallel python

2011-10-17 Thread tinux

I have around 100 python files, that each create one figure using matplotlib.
Since I want to use all CPU cores, I basically did "for filename in files:
execfile(filename)" using a python script. However, this does not produce
the same output as running each file separately (for instance axes, figure
size are sometime wrong).

I _think_ I narrowed it down to this: In all files I need to do
"matplotlib.rcParams(update)". I guess that this influences the matplotlib
rc parameters and thus somehow values from some figures are used for others. 

So, my question is, how can I do something like
"matplotlib.rcParams(update)" so that it does not influence other scripts
that are run in parallel using 'execfile'? Or, how do I set rc parameters
for one specific script?

BTW, I tried 'pp' and 'multiprocessing', same problem with both.

Any help is greatly appreciated!

Cheers, Martin
-- 
View this message in context: 
http://old.nabble.com/matplotlib.rcParams%28update%29-and-parallel-python-tp32669484p32669484.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users