@@ -906,7 +906,7 @@ def _open_file_or_url(fname):
906
906
_error_details_fmt = 'line #%d\n \t "%s"\n \t in file "%s"'
907
907
908
908
909
- def rc_params_in_file (fname , fail_on_error = False ):
909
+ def _rc_params_in_file (fname , fail_on_error = False ):
910
910
"""Return :class:`matplotlib.RcParams` from the contents of the given file.
911
911
912
912
Unlike `rc_params_from_file`, the configuration class only contains the
@@ -973,7 +973,7 @@ def rc_params_in_file(fname, fail_on_error=False):
973
973
return config
974
974
975
975
976
- def rc_params_from_file (fname , fail_on_error = False ):
976
+ def rc_params_from_file (fname , fail_on_error = False , use_default_template = True ):
977
977
"""Return :class:`matplotlib.RcParams` from the contents of the given file.
978
978
979
979
Parameters
@@ -982,12 +982,19 @@ def rc_params_from_file(fname, fail_on_error=False):
982
982
Name of file parsed for matplotlib settings.
983
983
fail_on_error : bool
984
984
If True, raise an error when the parser fails to convert a parameter.
985
+ use_default_template : bool
986
+ If True, initialize with default parameters before updating with those
987
+ in the given file. If False, the configuration class only contains the
988
+ parameters specified in the file. (Useful for updating dicts.)
985
989
"""
990
+ config_from_file = _rc_params_in_file (fname , fail_on_error )
986
991
987
- config = RcParams ([( key , default )
988
- for key , ( default , _ ) in six . iteritems ( defaultParams )])
992
+ if not use_default_template :
993
+ return config_from_file
989
994
990
- config .update (rc_params_in_file (fname , fail_on_error ))
995
+ iter_params = six .iteritems (defaultParams )
996
+ config = RcParams ([(key , default ) for key , (default , _ ) in iter_params ])
997
+ config .update (config_from_file )
991
998
992
999
verbose .set_level (config ['verbose.level' ])
993
1000
verbose .set_fileo (config ['verbose.fileo' ])
0 commit comments