On Mon, Oct 17, 2011 at 2:57 PM, tinux <hoffmann.mar...@gmail.com> 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

Reply via email to