From: John H. <jd...@gm...> - 2011-01-05 14:04:58
|
On Tue, Jan 4, 2011 at 4:40 PM, Sandro Tosi <mo...@de...> wrote: > Hi all, > > On Thu, Dec 9, 2010 at 23:04, Ben Gamari <bg...@gm...> wrote: > > On Thu, 09 Dec 2010 16:44:37 -0500, Ben Gamari <bg...@gm...> > wrote: > >> rcdefaults()'s implementation appears to implement the latter, updating > >> rcParams from rcParamsDefault in rcsetup.py, which appears to describe > >> the factory default values. Perhaps we should > >> rcParamsDefault.update(rcParams) after loading matplotlibrc? > >> > > As expected, doing the update of rcParamsDefault proposed above (patch > > below) allows the examples.download setting to persist throughout the > > documentation build. It seems like either the documentation build > > process or rcParamsDefault has been badly broken for a very long > > time. Is rcParamsDefault really supposed to be the factory defaults or > > is this just a bug? If the former, we will need to introduce a variant > > of matplotlib.rcdefaults() to reset the configuration to that specified > > in matplotlibrc. > I agree the current behavior needs to be improved. I'm testing a change now which utilizes two functions, now properly documented, and removing the hack in the plot_directive since the file defaults will be preserved. This keeps the current behavior, since rcdefaults is unchanged, but fixes the doc string, and introduces a new function with the desired behavior. Index: doc/matplotlibrc =================================================================== --- doc/matplotlibrc (revision 8886) +++ doc/matplotlibrc (working copy) @@ -232,7 +232,7 @@ ### FIGURE # See http://matplotlib.sourceforge.net/matplotlib.figure.html#Figure -figure.figsize : 6, 4 # figure size in inches +figure.figsize : 5.5, 4.5 # figure size in inches #figure.dpi : 80 # figure dots per inch #figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray #figure.edgecolor : white # figure edgecolor Index: lib/matplotlib/__init__.py =================================================================== --- lib/matplotlib/__init__.py (revision 8886) +++ lib/matplotlib/__init__.py (working copy) @@ -762,6 +762,7 @@ # this is the instance used by the matplotlib classes rcParams = rc_params() +rcParamsOrig = rcParams.copy() rcParamsDefault = RcParams([ (key, default) for key, (default, converter) in \ defaultParams.iteritems() ]) @@ -843,11 +844,19 @@ def rcdefaults(): """ - Restore the default rc params - the ones that were created at - matplotlib load time. + Restore the default rc params - these are not the params loaded by + the rc file, but mpl's internal params. See rc_file_defaults for + reloading the default params from the rc file """ rcParams.update(rcParamsDefault) +def rc_file_defaults(): + """ + Restore the default rc params from the original matplotlib rc that + was loaded + """ + rcParams.update(rcParamsOrig) + _use_error_msg = """ This call to matplotlib.use() has no effect because the the backend has already been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot, |