matplotlib.pyplot.rc#

matplotlib.pyplot.rc(group,**kwargs)[source]#

Set the currentrcParams.group is the grouping for the rc, e.g.,forlines.linewidth the group islines, foraxes.facecolor, the group isaxes, and so on. Group mayalso be a list or tuple of group names, e.g., (xtick,ytick).kwargs is a dictionary attribute name/value pairs, e.g.,:

rc('lines',linewidth=2,color='r')

sets the currentrcParams and is equivalent to:

rcParams['lines.linewidth']=2rcParams['lines.color']='r'

The following aliases are available to save typing for interactive users:

Alias

Property

'lw'

'linewidth'

'ls'

'linestyle'

'c'

'color'

'fc'

'facecolor'

'ec'

'edgecolor'

'mew'

'markeredgewidth'

'aa'

'antialiased'

'sans'

'sans-serif'

Thus you could abbreviate the above call as:

rc('lines',lw=2,c='r')

Note you can use python's kwargs dictionary facility to storedictionaries of default parameters. e.g., you can customize thefont rc as follows:

font={'family':'monospace','weight':'bold','size':'larger'}rc('font',**font)# pass in the font dict as kwargs

This enables you to easily switch between several configurations. Usematplotlib.style.use('default') orrcdefaults() torestore the defaultrcParams after changes.

Notes

Note

This is equivalent tomatplotlib.rc.

Similar functionality is available by using the normal dict interface, i.e.rcParams.update({"lines.linewidth":2,...}) (butrcParams.updatedoes not support abbreviations or grouping).

Examples usingmatplotlib.pyplot.rc#

Dashed line style configuration

Dashed line style configuration

Styling with cycler

Styling with cycler