Styles in GooseMPL¶
The following styles are part of GooseMPL (they become available upon installing GooseMPL):
Customized layout settings.
Extend a style to enable the use of LaTeX, and change the font to LaTeX default Computer Modern font.
Place the tick-markers (the little lines) at the inside of the axes rather than at the outside.
Shown only axes on the bottom and left side of the figure (those on the top and right are not shown).
See the Examples.
Matplotlib has a very convenient way to customize plots while minimizing the amount of customized code needed for this. It employs easy-to-switch plotting styles with the same parameters as a
matplotlibrc file. The only thing needed to switch styles is:
import matplotlib.pyplot as plt plt.style.use('name_of_custom_style')
A number of styles are available. To list them use
Also, one can use one’s own style. This is a plain-text file
name_of_custom_style.mplstyle stored in a sub-directory
stylelib of the Matplotlib configuration directory; e.g.:
~/.matplotlib/stylelib/ # MacOS/Linux ~/.config/matplotlib/stylelib/ # MacOS/Linux
The exact directory depends on the operating system and the installation. To find the directory to use on your system, use:
import matplotlib matplotlib.get_configdir()
More information in the matplotlib documentation
Combining different styles is easily accomplished by including a list of styles. For example:
To compose parts of the plot with a different style use:
with plt.style.context(('presentation')): plt.plot(np.sin(np.linspace(0, 2 * np.pi)))
To get the available fields do the following:
import matplotlib as mpl print(mpl.rcParams)