import matplotlib as mpl
import matplotlib.pyplot as pltLoads and uses the functions and style sheets defined in the package nice-figures
from nice_figures import *
fig_sizes = load_style() # update rcParams, get figure size
cols = load_cols() # load dictionary of custom colours
add_numbering(ax, i=0, loc=(0.8, 0.8)) # add numbers to figure panels
add_border() # add border to figureHere are some useful rcParams to remember:
mpl.rcParams['figure.dpi'] = 200c_bar = plt.colorbar()
c_bar.set_label('colorbar label')Use plt.getp(object_handle) and plt.setp(object_handle) (see here)
>>> line, = ax.plot(x, y, color='r')
>>> plt.getp(line) # lists all available attributes
agg_filter = None
alpha = None
animated = False
...
>>> plt.getp(line, 'color') # get color attribute
'r'
>>> plt.setp(line, color='b', linewidth=2) # set color and linewidth
>>> line.get_color() # sometime specific functions exist for getting specific attributes
'b'fig, axs = plt.sublots(2, 2, constrained_layout=True)
fig.suptitle('Figure title')Note that it is important to set constrained_layout=True otherwise title may overlap with subplots.
Use zorder to control which lines appear on top of which, with zorder < 0 appearing behind zorder > 0, e.g.,
ax.plot(x, y, zorder = 10) # appears in front
ax.plot(x, y, zorder = -5) # appears behindax.fill_between(x, y1, y2)