<divclass="bd-toc-item navbar-nav"><ulclass="current nav bd-sidenav">
<liclass="toctree-l1 current active has-children"><aclass="current reference internal" href="#">Setting up Matplotlib for development</a><inputchecked="" class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/><labelclass="toctree-toggle" for="toctree-checkbox-1"><iclass="fa-solid fa-chevron-down"></i></label><ul>
<liclass="toctree-l2"><aclass="reference internal" href="MEP/MEP12.html">MEP12: Improve Gallery and Examples</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="MEP/MEP13.html">MEP13: Use properties for Artists</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="MEP/MEP14.html">MEP14: Text handling</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="MEP/MEP15.html">MEP15: Fix axis autoscaling when limits are specified for one axis only</a></li>
<spanid="installing-for-devs"></span><h1>Setting up Matplotlib for development<aclass="headerlink" href="#setting-up-matplotlib-for-development" title="Link to this heading">#</a></h1>
<p>To set up Matplotlib for development follow these steps:</p>
<navclass="contents local" id="contents">
<ulclass="simple">
<li><p><aclass="reference internal" href="#fork-the-matplotlib-repository" id="id1">Fork the Matplotlib repository</a></p></li>
<li><p><aclass="reference internal" href="#retrieve-the-latest-version-of-the-code" id="id2">Retrieve the latest version of the code</a></p></li>
<li><p><aclass="reference internal" href="#create-a-dedicated-environment" id="id3">Create a dedicated environment</a></p></li>
<h2><aclass="toc-backref" href="#id1" role="doc-backlink">Fork the Matplotlib repository</a><aclass="headerlink" href="#fork-the-matplotlib-repository" title="Link to this heading">#</a></h2>
<p>Matplotlib is hosted at <aclass="github reference external" href="https://github.com/matplotlib/matplotlib.git">matplotlib/matplotlib.git</a>. If you
plan on solving issues or submitting pull requests to the main Matplotlib
repository, you should first <em>fork</em> this repository by visiting
<aclass="github reference external" href="https://github.com/matplotlib/matplotlib.git">matplotlib/matplotlib.git</a> and clicking on the
<codeclass="docutils literal notranslate"><spanclass="pre">Fork</span></code><svgversion="1.1" width="1.0em" height="1.0em" class="sd-octicon sd-octicon-repo-forked" viewBox="0 0 16 16" aria-hidden="true"><pathfill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg> button on the top right of the page. See
<h2><aclass="toc-backref" href="#id2" role="doc-backlink">Retrieve the latest version of the code</a><aclass="headerlink" href="#retrieve-the-latest-version-of-the-code" title="Link to this heading">#</a></h2>
<p>Now that your fork of the repository lives under your GitHub username, you can
retrieve the most recent version of the source code with one of the following
commands (replace <codeclass="docutils literal notranslate"><spanclass="pre"><your-username></span></code> with your GitHub username):</p>
<p>This requires you to setup an <aclass="reference external" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh">SSH key</a> in advance, but saves you from
typing your password at every connection.</p>
</div>
</div>
<p>This will place the sources in a directory <codeclass="file docutils literal notranslate"><spanclass="pre">matplotlib</span></code> below your
current working directory and set the remote name <codeclass="docutils literal notranslate"><spanclass="pre">origin</span></code> to point to your
fork. Change into this directory before continuing:</p>
<p>Now set the remote name <codeclass="docutils literal notranslate"><spanclass="pre">upstream</span></code> to point to the Matplotlib main repository:</p>
<p>You can now use <codeclass="docutils literal notranslate"><spanclass="pre">upstream</span></code> to retrieve the most current snapshot of the source
code, as described in <aclass="reference internal" href="development_workflow.html#development-workflow"><spanclass="std std-ref">Development workflow</span></a>.</p>
<pclass="sd-card-text">For more information on <codeclass="docutils literal notranslate"><spanclass="pre">git</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">GitHub</span></code>, see:</p>
<li><pclass="sd-card-text"><aclass="reference external" href="https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project">GitHub-Contributing to a Project</a></p></li>
<spanid="dev-environment"></span><h2><aclass="toc-backref" href="#id3" role="doc-backlink">Create a dedicated environment</a><aclass="headerlink" href="#create-a-dedicated-environment" title="Link to this heading">#</a></h2>
<p>You should set up a dedicated environment to decouple your Matplotlib
development from other Python and Matplotlib installations on your system.</p>
<p>The simplest way to do this is to use either Python's virtual environment
<aclass="reference external" href="https://docs.python.org/3/library/venv.html">venv</a> or <aclass="reference external" href="https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html">conda</a>.</p>
<spanclass="o"><</span><spanclass="n">file</span><spanclass="n">folder</span><spanclass="n">location</span><spanclass="o">></span>\<spanclass="n">Scripts</span>\<spanclass="n">activate</span><spanclass="o">.</span><spanclass="n">bat</span><spanclass="c1"># Windows cmd.exe</span>
<spanclass="o"><</span><spanclass="n">file</span><spanclass="n">folder</span><spanclass="n">location</span><spanclass="o">></span>\<spanclass="n">Scripts</span>\<spanclass="n">Activate</span><spanclass="o">.</span><spanclass="n">ps1</span><spanclass="c1"># Windows PowerShell</span>
</pre></div>
</div>
<p>On some systems, you may need to type <codeclass="docutils literal notranslate"><spanclass="pre">python3</span></code> instead of <codeclass="docutils literal notranslate"><spanclass="pre">python</span></code>.
For a discussion of the technical reasons, see <aclass="reference external" href="https://peps.python.org/pep-0394">PEP-394</a>.</p>
<p>Create a new <aclass="reference external" href="https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html">conda</a> environment and install the Python dependencies with</p>
<p>You can use <codeclass="docutils literal notranslate"><spanclass="pre">mamba</span></code> instead of <codeclass="docutils literal notranslate"><spanclass="pre">conda</span></code> in the above command if
you have <aclass="reference external" href="https://mamba.readthedocs.io/en/latest/">mamba</a> installed.</p>
<p>Remember to activate the environment whenever you start working on Matplotlib.</p>
</section>
<sectionid="install-dependencies">
<h2><aclass="toc-backref" href="#id4" role="doc-backlink">Install Dependencies</a><aclass="headerlink" href="#install-dependencies" title="Link to this heading">#</a></h2>
<p>Most Python dependencies will be installed when <aclass="reference internal" href="#dev-environment"><spanclass="std std-ref">setting up the environment</span></a>
but non-Python dependencies like C++ compilers, LaTeX, and other system applications
<liclass="toctree-l2"><aclass="reference internal" href="../users/installing/dependencies.html#dependencies-for-building-matplotlib">Dependencies for building Matplotlib</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../users/installing/dependencies.html#dependencies-for-testing-matplotlib">Dependencies for testing Matplotlib</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../users/installing/dependencies.html#dependencies-for-building-matplotlib-s-documentation">Dependencies for building Matplotlib's documentation</a></li>
</ul>
</li>
</ul>
</div>
</section>
<sectionid="install-matplotlib-in-editable-mode">
<spanid="development-install"></span><h2><aclass="toc-backref" href="#id5" role="doc-backlink">Install Matplotlib in editable mode</a><aclass="headerlink" href="#install-matplotlib-in-editable-mode" title="Link to this heading">#</a></h2>
<p>Install Matplotlib in editable mode from the <codeclass="file docutils literal notranslate"><spanclass="pre">matplotlib</span></code> directory
<p>If the installation is not working, please consult the <aclass="reference internal" href="troubleshooting.html#troubleshooting-faq"><spanclass="std std-ref">troubleshooting guide</span></a>.
If the guide does not offer a solution, please reach out via <aclass="reference external" href="https://gitter.im/matplotlib/matplotlib">chat</a>
or <aclass="reference internal" href="contribute.html#submitting-a-bug-report"><spanclass="std std-ref">open an issue</span></a>. For a list of environment variables
you can set before install, see <aclass="reference internal" href="../users/installing/environment_variables_faq.html#environment-variables"><spanclass="std std-ref">Environment variables</span></a>.</p>
</section>
<sectionid="verify-the-installation">
<h2><aclass="toc-backref" href="#id6" role="doc-backlink">Verify the Installation</a><aclass="headerlink" href="#verify-the-installation" title="Link to this heading">#</a></h2>
<p>Run the following command to make sure you have correctly installed Matplotlib in editable mode.
The command should be run when the virtual environment is activated</p>
<p>This command should return : <codeclass="docutils literal notranslate"><spanclass="pre"><matplotlib_local_repo>\lib\matplotlib\__init__.py</span></code></p>
<p>We encourage you to run tests and build docs to verify that the code installed correctly and that the docs build cleanly,
so that when you make code or document related changes you are aware of the existing issues beforehand.</p>
<blockquote>
<div><ulclass="simple">
<li><p>Run test cases to verify installation <aclass="reference internal" href="testing.html#testing"><spanclass="std std-ref">Testing</span></a></p></li>
<spanid="pre-commit-hooks"></span><h2><aclass="toc-backref" href="#id7" role="doc-backlink">Install pre-commit hooks</a><aclass="headerlink" href="#install-pre-commit-hooks" title="Link to this heading">#</a></h2>
<p><aclass="reference external" href="https://pre-commit.com/">pre-commit</a> hooks save time in the review process by
identifying issues with the code before a pull request is formally opened. Most
hooks can also aide in fixing the errors, and the checks should have
corresponding <aclass="reference internal" href="development_workflow.html#development-workflow"><spanclass="std std-ref">development workflow</span></a> and
<aclass="reference internal" href="coding_guide.html#pr-guidelines"><spanclass="std std-ref">pull request</span></a> guidelines. Hooks are configured in
<p>Hooks are run automatically after the <codeclass="docutils literal notranslate"><spanclass="pre">git</span><spanclass="pre">commit</span></code> stage of the
<aclass="reference internal" href="development_workflow.html#edit-flow"><spanclass="std std-ref">editing workflow</span></a>. When a hook has found and fixed an error in a
file, that file must be <em>staged and committed</em> again.</p>
<p>Hooks can also be run manually. All the hooks can be run, in order as
listed in <codeclass="docutils literal notranslate"><spanclass="pre">.pre-commit-config.yaml</span></code>, against the full codebase with</p>
<p>To run a particular hook manually, run <codeclass="docutils literal notranslate"><spanclass="pre">pre-commit</span><spanclass="pre">run</span></code> with the hook id</p>
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#fork-the-matplotlib-repository">Fork the Matplotlib repository</a></li>
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#retrieve-the-latest-version-of-the-code">Retrieve the latest version of the code</a></li>
<liclass="toc-h2 nav-item toc-entry"><aclass="reference internal nav-link" href="#create-a-dedicated-environment">Create a dedicated environment</a></li>