On this page
matplotlib
Backend management
- matplotlib.- use(backend, *, force=True)[source]
- 
    Select the backend used for rendering and GUI integration. Parameters: - backendstr
- 
           The backend to switch to. This can either be one of the standard backend names, which are case-insensitive: - interactive backends: GTK3Agg, GTK3Cairo, MacOSX, nbAgg, Qt4Agg, Qt4Cairo, Qt5Agg, Qt5Cairo, TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo
- non-interactive backends: agg, cairo, pdf, pgf, ps, svg, template
 or a string of the form: module://my.module.name.
- forcebool, default: True
- 
           If True (the default), raise an ImportErrorif the backend cannot be set up (either because it fails to import, or because an incompatible GUI interactive framework is already running); if False, ignore the failure.
 See also 
- matplotlib.- get_backend()[source]
- 
    Return the name of the current backend. See also 
- matplotlib.- interactive(b)[source]
- 
    Set whether to redraw after every plotting command (e.g. pyplot.xlabel).
- matplotlib.- is_interactive()[source]
- 
    Return whether to redraw after every plotting command. Note This function is only intended for use in backends. End users should use pyplot.isinteractiveinstead.
Default values and styling
- matplotlib.- rcParams
- 
    An instance of RcParamsfor handling default Matplotlib values.
- class matplotlib.RcParams(*args, **kwargs)[source]
- 
    A dictionary object including validation. Validating functions are defined and associated with rc parameters in matplotlib.rcsetup.The list of rcParams is: - backend
- backend_fallback
- toolbar
- interactive
- timezone
- webagg.port
- webagg.address
- webagg.open_in_browser
- webagg.port_retries
- lines.linewidth
- lines.linestyle
- lines.color
- lines.marker
- lines.markerfacecolor
- lines.markeredgecolor
- lines.markeredgewidth
- lines.markersize
- lines.antialiased
- lines.dash_joinstyle
- lines.solid_joinstyle
- lines.dash_capstyle
- lines.solid_capstyle
- lines.dashed_pattern
- lines.dashdot_pattern
- lines.dotted_pattern
- lines.scale_dashes
- markers.fillstyle
- pcolor.shading
- pcolormesh.snap
- patch.linewidth
- patch.edgecolor
- patch.force_edgecolor
- patch.facecolor
- patch.antialiased
- hatch.color
- hatch.linewidth
- hist.bins
- boxplot.notch
- boxplot.vertical
- boxplot.whiskers
- boxplot.bootstrap
- boxplot.patchartist
- boxplot.showmeans
- boxplot.showcaps
- boxplot.showbox
- boxplot.showfliers
- boxplot.meanline
- boxplot.flierprops.color
- boxplot.flierprops.marker
- boxplot.flierprops.markerfacecolor
- boxplot.flierprops.markeredgecolor
- boxplot.flierprops.markeredgewidth
- boxplot.flierprops.markersize
- boxplot.flierprops.linestyle
- boxplot.flierprops.linewidth
- boxplot.boxprops.color
- boxplot.boxprops.linewidth
- boxplot.boxprops.linestyle
- boxplot.whiskerprops.color
- boxplot.whiskerprops.linewidth
- boxplot.whiskerprops.linestyle
- boxplot.capprops.color
- boxplot.capprops.linewidth
- boxplot.capprops.linestyle
- boxplot.medianprops.color
- boxplot.medianprops.linewidth
- boxplot.medianprops.linestyle
- boxplot.meanprops.color
- boxplot.meanprops.marker
- boxplot.meanprops.markerfacecolor
- boxplot.meanprops.markeredgecolor
- boxplot.meanprops.markersize
- boxplot.meanprops.linestyle
- boxplot.meanprops.linewidth
- font.family
- font.style
- font.variant
- font.stretch
- font.weight
- font.size
- font.serif
- font.sans-serif
- font.cursive
- font.fantasy
- font.monospace
- text.color
- text.usetex
- text.latex.preamble
- text.latex.preview
- text.hinting
- text.hinting_factor
- text.kerning_factor
- text.antialiased
- mathtext.cal
- mathtext.rm
- mathtext.tt
- mathtext.it
- mathtext.bf
- mathtext.sf
- mathtext.fontset
- mathtext.default
- mathtext.fallback_to_cm
- mathtext.fallback
- image.aspect
- image.interpolation
- image.cmap
- image.lut
- image.origin
- image.resample
- image.composite_image
- contour.negative_linestyle
- contour.corner_mask
- contour.linewidth
- errorbar.capsize
- xaxis.labellocation
- yaxis.labellocation
- axes.axisbelow
- axes.facecolor
- axes.edgecolor
- axes.linewidth
- axes.spines.left
- axes.spines.right
- axes.spines.bottom
- axes.spines.top
- axes.titlesize
- axes.titlelocation
- axes.titleweight
- axes.titlecolor
- axes.titley
- axes.titlepad
- axes.grid
- axes.grid.which
- axes.grid.axis
- axes.labelsize
- axes.labelpad
- axes.labelweight
- axes.labelcolor
- axes.formatter.limits
- axes.formatter.use_locale
- axes.formatter.use_mathtext
- axes.formatter.min_exponent
- axes.formatter.useoffset
- axes.formatter.offset_threshold
- axes.unicode_minus
- axes.prop_cycle
- axes.autolimit_mode
- axes.xmargin
- axes.ymargin
- axes.zmargin
- polaraxes.grid
- axes3d.grid
- scatter.marker
- scatter.edgecolors
- date.epoch
- date.autoformatter.year
- date.autoformatter.month
- date.autoformatter.day
- date.autoformatter.hour
- date.autoformatter.minute
- date.autoformatter.second
- date.autoformatter.microsecond
- date.converter
- date.interval_multiples
- legend.fancybox
- legend.loc
- legend.numpoints
- legend.scatterpoints
- legend.fontsize
- legend.title_fontsize
- legend.markerscale
- legend.shadow
- legend.frameon
- legend.framealpha
- legend.borderpad
- legend.labelspacing
- legend.handlelength
- legend.handleheight
- legend.handletextpad
- legend.borderaxespad
- legend.columnspacing
- legend.facecolor
- legend.edgecolor
- xtick.top
- xtick.bottom
- xtick.labeltop
- xtick.labelbottom
- xtick.major.size
- xtick.minor.size
- xtick.major.width
- xtick.minor.width
- xtick.major.pad
- xtick.minor.pad
- xtick.color
- xtick.labelcolor
- xtick.minor.visible
- xtick.minor.top
- xtick.minor.bottom
- xtick.major.top
- xtick.major.bottom
- xtick.labelsize
- xtick.direction
- xtick.alignment
- ytick.left
- ytick.right
- ytick.labelleft
- ytick.labelright
- ytick.major.size
- ytick.minor.size
- ytick.major.width
- ytick.minor.width
- ytick.major.pad
- ytick.minor.pad
- ytick.color
- ytick.labelcolor
- ytick.minor.visible
- ytick.minor.left
- ytick.minor.right
- ytick.major.left
- ytick.major.right
- ytick.labelsize
- ytick.direction
- ytick.alignment
- grid.color
- grid.linestyle
- grid.linewidth
- grid.alpha
- figure.titlesize
- figure.titleweight
- figure.figsize
- figure.dpi
- figure.facecolor
- figure.edgecolor
- figure.frameon
- figure.autolayout
- figure.max_open_warning
- figure.raise_window
- figure.subplot.left
- figure.subplot.right
- figure.subplot.bottom
- figure.subplot.top
- figure.subplot.wspace
- figure.subplot.hspace
- figure.constrained_layout.use
- figure.constrained_layout.hspace
- figure.constrained_layout.wspace
- figure.constrained_layout.h_pad
- figure.constrained_layout.w_pad
- savefig.dpi
- savefig.facecolor
- savefig.edgecolor
- savefig.orientation
- savefig.jpeg_quality
- savefig.format
- savefig.bbox
- savefig.pad_inches
- savefig.directory
- savefig.transparent
- tk.window_focus
- ps.papersize
- ps.useafm
- ps.usedistiller
- ps.distiller.res
- ps.fonttype
- pdf.compression
- pdf.inheritcolor
- pdf.use14corefonts
- pdf.fonttype
- pgf.texsystem
- pgf.rcfonts
- pgf.preamble
- svg.image_inline
- svg.fonttype
- svg.hashsalt
- docstring.hardcopy
- path.simplify
- path.simplify_threshold
- path.snap
- path.sketch
- path.effects
- agg.path.chunksize
- keymap.fullscreen
- keymap.home
- keymap.back
- keymap.forward
- keymap.pan
- keymap.zoom
- keymap.save
- keymap.quit
- keymap.quit_all
- keymap.grid
- keymap.grid_minor
- keymap.yscale
- keymap.xscale
- keymap.all_axes
- keymap.help
- keymap.copy
- animation.html
- animation.embed_limit
- animation.writer
- animation.codec
- animation.bitrate
- animation.frame_format
- animation.html_args
- animation.ffmpeg_path
- animation.ffmpeg_args
- animation.avconv_path
- animation.avconv_args
- animation.convert_path
- animation.convert_args
- _internal.classic_mode
 See also - find_all(pattern)[source]
- 
      Return the subset of this RcParams dictionary whose keys match, using re.search(), the givenpattern.Note Changes to the returned dictionary are not propagated to the parent RcParams dictionary. 
 
- matplotlib.- rc_context(rc=None, fname=None)[source]
- 
    Return a context manager for temporarily changing rcParams. Parameters: - rcdict
- 
           The rcParams to temporarily set. 
- fnamestr or path-like
- 
           A file with Matplotlib rc settings. If both fname and rc are given, settings from rc take precedence. 
 See also ExamplesPassing explicit values via a dict: with mpl.rc_context({'interactive': False}): fig, ax = plt.subplots() ax.plot(range(3), range(3)) fig.savefig('example.png') plt.close(fig)Loading settings from a file: with mpl.rc_context(fname='print.rc'): plt.plot(x, y) # uses 'print.rc'
- matplotlib.- rc(group, **kwargs)[source]
- 
    Set the current rcParams. group is the grouping for the rc, e.g., forlines.linewidththe group islines, foraxes.facecolor, the group isaxes, and so on. Group may also 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 current rcParamsand is equivalent to:rcParams['lines.linewidth'] = 2 rcParams['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' Thus you could abbreviate the above call as: rc('lines', lw=2, c='r')Note you can use python's kwargs dictionary facility to store dictionaries of default parameters. e.g., you can customize the font rc as follows: font = {'family' : 'monospace', 'weight' : 'bold', 'size' : 'larger'} rc('font', **font) # pass in the font dict as kwargsThis enables you to easily switch between several configurations. Use matplotlib.style.use('default')orrcdefaults()to restore the defaultrcParamsafter changes.NotesSimilar functionality is available by using the normal dict interface, i.e. rcParams.update({"lines.linewidth": 2, ...})(butrcParams.updatedoes not support abbreviations or grouping).
- matplotlib.- rcdefaults()[source]
- 
    Restore the rcParamsfrom Matplotlib's internal default style.Style-blacklisted rcParams(defined inmatplotlib.style.core.STYLE_BLACKLIST) are not updated.See also - 
       matplotlib.rc_file_defaults
- 
       Restore the rcParamsfrom the rc file originally loaded by Matplotlib.
- 
       matplotlib.style.use
- 
       Use a specific style file. Call style.use('default')to restore the default style.
 
- 
       
- matplotlib.- rc_file_defaults()[source]
- 
    Restore the rcParamsfrom the original rc file loaded by Matplotlib.Style-blacklisted rcParams(defined inmatplotlib.style.core.STYLE_BLACKLIST) are not updated.
- matplotlib.- rc_file(fname, *, use_default_template=True)[source]
- 
    Update rcParamsfrom file.Style-blacklisted rcParams(defined inmatplotlib.style.core.STYLE_BLACKLIST) are not updated.Parameters: - fnamestr or path-like
- 
           A file with Matplotlib rc settings. 
- use_default_templatebool
- 
           If True, initialize with default parameters before updating with those in the given file. If False, the current configuration persists and only the parameters specified in the file are updated. 
 
- matplotlib.- rc_params(fail_on_error=False)[source]
- 
    Construct a RcParamsinstance from the default Matplotlib rc file.
- matplotlib.- rc_params_from_file(fname, fail_on_error=False, use_default_template=True)[source]
- 
    Construct a RcParamsfrom file fname.Parameters: - fnamestr or path-like
- 
           A file with Matplotlib rc settings. 
- fail_on_errorbool
- 
           If True, raise an error when the parser fails to convert a parameter. 
- use_default_templatebool
- 
           If True, initialize with default parameters before updating with those in the given file. If False, the configuration class only contains the parameters specified in the file. (Useful for updating dicts.) 
 
- matplotlib.- get_configdir()[source]
- 
    Return the string path of the the configuration directory. The directory is chosen as follows: - If the MPLCONFIGDIR environment variable is supplied, choose that.
- On Linux, follow the XDG specification and look first in $XDG_CONFIG_HOME, if defined, or$HOME/.config. On other platforms, choose$HOME/.matplotlib.
- If the chosen directory exists and is writable, use that as the configuration directory.
- Else, create a temporary directory, and use it as the configuration directory.
 
- matplotlib.- matplotlib_fname()[source]
- 
    Get the location of the config file. The file location is determined in the following order - $PWD/matplotlibrc
- $MATPLOTLIBRCif it is not a directory
- $MATPLOTLIBRC/matplotlibrc
- $MPLCONFIGDIR/matplotlibrc
- 
      - On Linux,
- 
        - $XDG_CONFIG_HOME/matplotlib/matplotlibrc(if- $XDG_CONFIG_HOMEis defined)
- or $HOME/.config/matplotlib/matplotlibrc(if$XDG_CONFIG_HOMEis not defined)
 
 
- On other platforms, - $HOME/.matplotlib/matplotlibrcif$HOMEis defined
- Lastly, it looks in $MATPLOTLIBDATA/matplotlibrc, which should always exist.
 
- matplotlib.- get_data_path()[source]
- 
    Return the path to Matplotlib data. 
Logging
- matplotlib.- set_loglevel(level)[source]
- 
    Set Matplotlib's root logger and root logger handler level, creating the handler if it does not exist yet. Typically, one should call set_loglevel("info")orset_loglevel("debug")to get additional debugging information.Parameters: - level{"notset", "debug", "info", "warning", "error", "critical"}
- 
           The log level of the handler. 
 NotesThe first time this function is called, an additional handler is attached to Matplotlib's root handler; this handler is reused every time and this function simply manipulates the logger and handler's level. 
Miscellaneous
- matplotlib.- get_cachedir()[source]
- 
    Return the string path of the cache directory. The procedure used to find the directory is the same as for _get_config_dir, except using $XDG_CACHE_HOME/$HOME/.cacheinstead.
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
 https://matplotlib.org/3.4.3/api/matplotlib_configuration_api.html