问题
I am learning matplotlib at the moment and working on changing the rcParams. The documentation on the website appears to be very sparse.
When I look here, there is only a select few examples of rc parameters that can be changed, mainly fonts or line colors, such as:
rcParams['lines.linewidth'] = 2
rcParams['lines.color'] = 'r'
And so forth. I am looking for ways to alter the grid and default figure size for example, but they are not listed here and are only scattered here and there across the web. I want to find a reference list of all the changeable parameters and their descriptions. Does such a reference exist?
Thanks.
回答1:
There is a complete tutorial about rc params: Customizing Matplotlib with style sheets and rcParams.
Further down that tutorial there is a section A sample matplotlibrc file, which contains all valid rc params.
Another option is to just print all rc params out,
print(plt.rcParams)
Concerning the actual question:
- The grid can be turned on via - plt.rcParams["axes.grid"] = True
- The figure size can be set via - plt.rcParams["figure.figsize"] = (8,6)
回答2:
From the documentation, you can find the location of the matplotlibrc on your machine as follows:
import matplotlib
matplotlib.matplotlib_fname()
In your text editor, you can uncomment the preset commands. This file is read whenever matplotlib is imported.
来源:https://stackoverflow.com/questions/53399602/how-to-change-defaults-in-matplot-lib-and-find-specific-list-of-rc-parameters