<divid="unreleased-message"> You are reading an old version of the documentation (v1.4.1). For the latest version see <ahref="https://matplotlib.org/stable/users/customizing.html">https://matplotlib.org/stable/users/customizing.html</a></div>
<spanid="id1"></span><h1>Customizing matplotlib<aclass="headerlink" href="#customizing-matplotlib" title="Permalink to this headline">¶</a></h1>
<divclass="section" id="the-matplotlibrc-file">
<spanid="customizing-with-matplotlibrc-files"></span><h2>The <codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> file<aclass="headerlink" href="#the-matplotlibrc-file" title="Permalink to this headline">¶</a></h2>
<p>matplotlib uses <codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> configuration files to customize all kinds
of properties, which we call <codeclass="xref py py-obj docutils literal"><spanclass="pre">rc</span><spanclass="pre">settings</span></code> or <codeclass="xref py py-obj docutils literal"><spanclass="pre">rc</span><spanclass="pre">parameters</span></code>. You can control
the defaults of almost every property in matplotlib: figure size and dpi, line
width, color and style, axes, axis and grid properties, text and font
properties and so on. matplotlib looks for <codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> in three
locations, in the following order:</p>
<olclass="arabic">
<li><pclass="first"><codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> in the current working directory, usually used for
specific customizations that you do not want to apply elsewhere.</p>
</li>
<li><pclass="first">It next looks in a user-specific place, depending on your platform:</p>
<ulclass="simple">
<li>On Linux, it looks in <codeclass="file docutils literal"><spanclass="pre">.config/matplotlib/matplotlibrc</span></code> (or
<codeclass="xref py py-obj docutils literal"><spanclass="pre">$XDG_CONFIG_HOME/matplotlib/matplotlibrc</span></code>) if you’ve customized
your environment.</li>
<li>On other platforms, it looks in <codeclass="file docutils literal"><spanclass="pre">.matplotlib/matplotlibrc</span></code>.</li>
<li><pclass="first"><codeclass="file docutils literal"><em><spanclass="pre">INSTALL</span></em><spanclass="pre">/matplotlib/mpl-data/matplotlibrc</span></code>, where
<codeclass="file docutils literal"><em><spanclass="pre">INSTALL</span></em></code> is something like
<codeclass="file docutils literal"><spanclass="pre">/usr/lib/python2.5/site-packages</span></code> on Linux, and maybe
<codeclass="file docutils literal"><spanclass="pre">C:\Python25\Lib\site-packages</span></code> on Windows. Every time you
install matplotlib, this file will be overwritten, so if you want
your customizations to be saved, please move this file to your
user-specific matplotlib directory.</p>
</li>
</ol>
<p>To display where the currently active <codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> file was
<p>See below for a sample <aclass="reference internal" href="#matplotlibrc-sample"><em>matplotlibrc file</em></a>.</p>
</div>
<divclass="section" id="dynamic-rc-settings">
<spanid="customizing-with-dynamic-rc-settings"></span><h2>Dynamic rc settings<aclass="headerlink" href="#dynamic-rc-settings" title="Permalink to this headline">¶</a></h2>
<p>You can also dynamically change the default rc settings in a python script or
interactively from the python shell. All of the rc settings are stored in a
dictionary-like variable called <aclass="reference internal" href="../api/matplotlib_configuration_api.html#matplotlib.rcParams" title="matplotlib.rcParams"><codeclass="xref py py-data docutils literal"><spanclass="pre">matplotlib.rcParams</span></code></a>, which is global to
the matplotlib package. rcParams can be modified directly, for example:</p>
<p>Matplotlib also provides a couple of convenience functions for modifying rc
settings. The <aclass="reference internal" href="../api/matplotlib_configuration_api.html#matplotlib.rc" title="matplotlib.rc"><codeclass="xref py py-func docutils literal"><spanclass="pre">matplotlib.rc()</span></code></a> command can be used to modify multiple
settings in a single group at once, using keyword arguments:</p>
<p>The <codeclass="xref py py-func docutils literal"><spanclass="pre">matplotlib.rcdefaults()</span></code> command will restore the standard matplotlib
default settings.</p>
<p>There is some degree of validation when setting the values of rcParams, see
<codeclass="xref py py-mod docutils literal"><spanclass="pre">matplotlib.rcsetup</span></code> for details.</p>
<spanid="matplotlibrc-sample"></span><h3>A sample matplotlibrc file<aclass="headerlink" href="#a-sample-matplotlibrc-file" title="Permalink to this headline">¶</a></h3>
<aclass="reference external" href="../_static/matplotlibrc">(download)</a><divclass="highlight-python"><divclass="highlight"><pre>### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overwritten in your next install.
# If you want to keep a permanent local copy that will not be
# overwritten, place it in the following location:
# unix/linux:
# $HOME/.config/matplotlib/matplotlibrc or
# $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set)
# other platforms:
# $HOME/.matplotlib/matplotlibrc
#
# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for
# more details on the paths which are checked for the configuration file.
#
# This file is best viewed in a editor which supports python mode
# syntax highlighting. Blank lines, or lines starting with a comment
# symbol, are ignored, as are trailing comments. Other lines must
# have the format
# key : val # optional comment
#
# Colors: for the color values below, you can either use - a
# matplotlib color string, such as r, k, or b - an rgb tuple, such as
# (1.0, 0.5, 0.0) - a hex string, such as ff00ff or #ff00ff - a scalar
# grayscale intensity such as 0.75 - a legal html color name, eg red,
# blue, darkslategray
#### CONFIGURATION BEGINS HERE
# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# expanded, extra-expanded, ultra-expanded, wider, and narrower. This
# property is not currently implemented.
#
# The font.size property is the default font size for text, given in pts.
# 12pt is the standard value.
#
#font.family : sans-serif
#font.style : normal
#font.variant : normal
#font.weight : medium
#font.stretch : normal
# note that font.size controls default text sizes. To configure
# special text sizes tick labels, axes, labels, title, etc, see the rc
# settings for axes and ticks. Special text sizes can be defined
# relative to font.size, using the following values: xx-small, x-small,
# small, medium, large, x-large, xx-large, larger, or smaller
#font.size : 12.0
#font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
#font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
### TEXT
# text properties used by text.Text. See
# http://matplotlib.org/api/artist_api.html#module-matplotlib.text for more
# information on text properties
#text.color : black
### LaTeX customizations. See http://www.scipy.org/Wiki/Cookbook/Matplotlib/UsingTex
#text.usetex : False # use latex for all text handling. The following fonts
# are supported through the usual rc parameter settings:
# new century schoolbook, bookman, times, palatino,