Description
The matplotlibrc.template
is a useful resource in the documentation to quickly check for available options for styling, as well as for creating custom styles. Yet it is constantly out of date compared to the available rcParams
in the library.
Missing entries in the matplotlibrc
Currently the following available rcParams
are availble but not listed in the matplotlibrc.template
file:
path.effects : []
savefig.orientation : portrait
savefig.frameon : True
figure.constrained_layout.h_pad : 0.04167
figure.constrained_layout.w_pad : 0.04167
figure.constrained_layout.hspace : 0.02
figure.constrained_layout.wspace : 0.02
figure.frameon : True
axes.hold : None
axes.grid.axis : both
axes.grid.which : major
axes.titleweight : normal
verbose.level : silent
keymap.quit_all : ['W', 'cmd+W', 'Q']
ytick.alignment : center_baseline
xtick.alignment : center
pgf.rcfonts : True
pgf.preamble : []
pgf.texsystem : xelatex
pgf.debug : False
pdf.use14corefonts : False
pdf.inheritcolor : False
backend.qt4 : None
backend.qt5 : None
animation.embed_limit : 20.0
text.latex.preview : False
verbose.fileo : sys.stdout
_internal.classic_mode : False
Are any of those parameters meant to not be part of the template? I suppose those starting with "_"
?
Creating a test to check if template is up to date
To avoid having the template being out of sync it could make sense to add a test. Essentially going through the parameters and see if they are in the template or not.
import matplotlib
def test_if_rctemplate_is_up_to_date():
path_to_rc = matplotlib.matplotlib_fname()
with open(path_to_rc, "r") as f:
rclines = f.readlines()
missing = {}
for k,v in matplotlib.rcParams.items():
if k[0] == "_": continue;
found = False
for line in rclines:
if k in line:
found = True
if not found:
missing.update({k:v})
if missing:
#for k,v in missing.items():
# print("{} : {}".format(k,v))
assert False
test_if_rctemplate_is_up_to_date()
Question: Is this useful? If so, what would be the value for path_to_rc
such that the test can run on Travis?
Creating a test to check if template is valid
Ideally one would also check if the template is actually a valid rc file in case the params are uncommented. This is currently hard because lines containing possible params are commented with a single #
, just as all real comments. If the file was edited to have lines with parameters starting with a single #
and lines with comments with several ##
,
## comment about the rcparam
#valid.rcparams : value ## explanation
## further explanation
one could write a test that reads in the file, removes leading #
, and load it as style.
Question: Would this be desirable? I remember reading there was a plan to change the style files to python files, in which case it would not make sense to put that much effort into this.