.matplotlibrc and default options

前端 未结 1 1847
醉话见心
醉话见心 2020-12-19 20:46

I am studying the matplotlib library for Python. I am starting to understand some of its basic intricacies, as the difference between pylab and pyplot, and I am trying to re

相关标签:
1条回答
  • 2020-12-19 21:21

    Judging from the documentation and the code in matplotlib\__init__.py in the site packages directory you can see that the search path for the matplotlibrc file is:

    Search order:                                                                                                                             
    
     * current working dir                                                                                                                    
     * environ var MATPLOTLIBRC                                                                                                               
     * HOME/.matplotlib/matplotlibrc                                                                                                          
     * MATPLOTLIBDATA/matplotlibrc
    

    and if no file is found in these paths a warning is raised:

    warnings.warn('Could not find matplotlibrc; using defaults')
    

    The matplotlibrc file is just an update to the existing default parameters. These can be found using:

    from matplotlib.rcsetup import defaultParams
    

    (this is obviously in matplotlib/rcsetup.py)

    In the __init__.py file, matplotlib cycles through this dictionary and defines the default rc parameter that will be used for all scripts and codes:

    rcParamsDefault = RcParams([ (key, default) for key, (default, converter) in \
                        defaultParams.iteritems() ])
    

    So if you want to know the defaults, look at:

    In [4]: import matplotlib
    
    In [5]: matplotlib.rcParamsDefault
    Out[5]: 
    {'agg.path.chunksize': 0,
     'animation.bitrate': -1,
     'animation.codec': 'mpeg4',
     'animation.ffmpeg_args': '',
     'animation.ffmpeg_path': 'ffmpeg',
     'animation.frame_format': 'png',
     'animation.mencoder_args': '',
     'animation.mencoder_path': 'mencoder',
     'animation.writer': 'ffmpeg',
     ...
    
    0 讨论(0)
提交回复
热议问题