Only using a rcParams that are defined in matplotlibrc

The rcParams list seems to list all settings regardless of whether or not they are defined in matplotlibrc.

If I want the figure.facecolor to be white unless the user defines it as something else in his or her matplotlibrc file, is there an easy way to do that short of opening up matplotlib_fname() and parsing it myself?

figure.facecolor in returns True despite the fact that it is not defined in matplotlibrc.

The following works, but it seems like there should be an easier way of doing this

        f = open(matplotlib.matplotlib_fname(),'r')
        settings = [ line.split(':')[0].strip() for line in f.readlines() if not line.strip().startswith('#') and line.split(':')[0].strip() != '' ]
        if not 'figure.facecolor' in settings:
            raise ValueError
        matplotlib.rcParams['figure.facecolor'] = '#FFFFFF'


  • Rob Falck