<spanid="pr-guidelines"></span><h1>Pull request guidelines<aclass="headerlink" href="#pull-request-guidelines" title="Permalink to this headline">#</a></h1>
<p>Pull requests (PRs) are the mechanism for contributing to Matplotlibs code and
documentation.</p>
<sectionid="summary-for-pull-request-authors">
<h2>Summary for pull request authors<aclass="headerlink" href="#summary-for-pull-request-authors" title="Permalink to this headline">#</a></h2>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<ulclass="simple">
<li><p>We value contributions from people with all levels of experience. In
particular if this is your first PR not everything has to be perfect.
We'll guide you through the PR process.</p></li>
<li><p>Nevertheless, please try to follow the guidelines below as well as you can to
help make the PR process quick and smooth.</p></li>
<li><p>Be patient with reviewers. We try our best to respond quickly, but we
have limited bandwidth. If there is no feedback within a couple of days,
please ping us by posting a comment to your PR.</p></li>
</ul>
</div>
<p>When making a PR, pay attention to:</p>
<ulclass="checklist">
<li><p><aclass="reference internal" href="#pr-branch-selection"><spanclass="std std-ref">Target the master branch</span></a>.</p></li>
<li><p>Adhere to the <aclass="reference internal" href="contributing.html#coding-guidelines"><spanclass="std std-ref">Coding guidelines</span></a>.</p></li>
<li><p>Update the <aclass="reference internal" href="#pr-documentation"><spanclass="std std-ref">documentation</span></a> if necessary.</p></li>
<li><p>Aim at making the PR as "ready-to-go" as you can. This helps to speed up
the review process.</p></li>
<li><p>It is ok to open incomplete or work-in-progress PRs if you need help or
feedback from the developers. You may mark these as
<p>See also <aclass="reference internal" href="contributing.html#contributing"><spanclass="std std-ref">Contributing</span></a> for how to make a PR.</p>
</section>
<sectionid="summary-for-pull-request-reviewers">
<h2>Summary for pull request reviewers<aclass="headerlink" href="#summary-for-pull-request-reviewers" title="Permalink to this headline">#</a></h2>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<ulclass="simple">
<li><p>If you have commit rights, then you are trusted to use them.
<strong>Please help review and merge PRs!</strong></p></li>
<li><p>Be patient and <aclass="reference external" href="https://youtu.be/tzFWz5fiVKU?t=49m30s">kind</a> with
contributors.</p></li>
</ul>
</div>
<p>Content topics:</p>
<ulclass="checklist simple">
<li><p>Is the feature / bugfix reasonable?</p></li>
<li><p>Does the PR conform with the <aclass="reference internal" href="contributing.html#coding-guidelines"><spanclass="std std-ref">Coding guidelines</span></a>?</p></li>
<li><p>Is the <aclass="reference internal" href="#pr-documentation"><spanclass="std std-ref">documentation</span></a> (docstrings, examples,
what's new, API changes) updated?</p></li>
</ul>
<p>Organizational topics:</p>
<ulclass="checklist simple">
<li><p>Make sure all <aclass="reference internal" href="#pr-automated-tests"><spanclass="std std-ref">automated tests</span></a> pass.</p></li>
<li><p>The PR should <aclass="reference internal" href="#pr-branch-selection"><spanclass="std std-ref">target the master branch</span></a>.</p></li>
<li><p>Tag with descriptive <aclass="reference internal" href="#pr-labels"><spanclass="std std-ref">labels</span></a>.</p></li>
<li><p>Set the <aclass="reference internal" href="#pr-milestones"><spanclass="std std-ref">milestone</span></a>.</p></li>
<li><p>Keep an eye on the <aclass="reference internal" href="#pr-squashing"><spanclass="std std-ref">number of commits</span></a>.</p></li>
<li><p>Approve if all of the above topics are handled.</p></li>
<li><p><aclass="reference internal" href="#pr-merging"><spanclass="std std-ref">Merge</span></a> if a sufficient number of approvals is reached.</p></li>
</ul>
</section>
<sectionid="detailed-guidelines">
<spanid="pr-guidelines-details"></span><h2>Detailed guidelines<aclass="headerlink" href="#detailed-guidelines" title="Permalink to this headline">#</a></h2>
<sectionid="documentation">
<spanid="pr-documentation"></span><h3>Documentation<aclass="headerlink" href="#documentation" title="Permalink to this headline">#</a></h3>
<ulclass="simple">
<li><p>Every new feature should be documented. If it's a new module, don't
forget to add a new rst file to the API docs.</p></li>
<li><p>Each high-level plotting function should have a small example in
the <codeclass="docutils literal notranslate"><spanclass="pre">Examples</span></code> section of the docstring. This should be as simple as
possible to demonstrate the method. More complex examples should go into
a dedicated example file in the <codeclass="file docutils literal notranslate"><spanclass="pre">examples</span></code> directory, which will be
rendered to the examples gallery in the documentation.</p></li>
<li><p>Build the docs and make sure all formatting warnings are addressed.</p></li>
<li><p>If you change the API in a backward-incompatible way, please
document it by adding a file in the relevant subdirectory of
<codeclass="file docutils literal notranslate"><spanclass="pre">doc/api/next_api_changes/</span></code>, probably in the <codeclass="docutils literal notranslate"><spanclass="pre">behavior/</span></code>
subdirectory.</p></li>
</ul>
</section>
<sectionid="labels">
<spanid="pr-labels"></span><h3>Labels<aclass="headerlink" href="#labels" title="Permalink to this headline">#</a></h3>
<ulclass="simple">
<li><p>If you have the rights to set labels, tag the PR with descriptive labels.
See the <aclass="reference external" href="https://github.com/matplotlib/matplotlib/labels">list of labels</a>.</p></li>
<li><p>If the PR makes changes to the wheel building Action, add the
"Run cibuildwheel" label to enable testing wheels.</p></li>
</ul>
</section>
<sectionid="milestones">
<spanid="pr-milestones"></span><h3>Milestones<aclass="headerlink" href="#milestones" title="Permalink to this headline">#</a></h3>
<ul>
<li><p>Set the milestone according to these rules:</p>
<ulclass="simple">
<li><p><em>New features and API changes</em> are milestoned for the next minor release
<p>If multiple rules apply, choose the first matching from the above list.</p>
<p>Setting a milestone does not imply or guarantee that a PR will be merged for that
release, but if it were to be merged what release it would be in.</p>
<p>All of these PRs should target the master branch. The milestone tag triggers
an <aclass="reference internal" href="#automated-backports"><spanclass="std std-ref">automatic backport</span></a> for milestones which have
a corresponding branch.</p>
</li>
</ul>
</section>
<sectionid="merging">
<spanid="pr-merging"></span><h3>Merging<aclass="headerlink" href="#merging" title="Permalink to this headline">#</a></h3>
<ul>
<li><p>Documentation and examples may be merged by the first reviewer. Use
the threshold "is this better than it was?" as the review criteria.</p></li>
<li><p>For code changes (anything in <codeclass="docutils literal notranslate"><spanclass="pre">src</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">lib</span></code>) at least two
core developers (those with commit rights) should review all pull
requests. If you are the first to review a PR and approve of the
changes use the GitHub <aclass="reference external" href="https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests">'approve review'</a>
tool to mark it as such. If you are a subsequent reviewer please
approve the review and if you think no more review is needed, merge
the PR.</p>
<p>Ensure that all API changes are documented in a file in one of the
subdirectories of <codeclass="file docutils literal notranslate"><spanclass="pre">doc/api/next_api_changes</span></code>, and significant new
features have an entry in <codeclass="file docutils literal notranslate"><spanclass="pre">doc/user/whats_new</span></code>.</p>
<ul>
<li><p>If a PR already has a positive review, a core developer (e.g. the first
reviewer, but not necessarily) may champion that PR for merging. In order
to do so, they should ping all core devs both on GitHub and on the dev
mailing list, and label the PR with the "Merge with single review?" label.
Other core devs can then either review the PR and merge or reject it, or
simply request that it gets a second review before being merged. If no one
asks for such a second review within a week, the PR can then be merged on
the basis of that single review.</p>
<p>A core dev should only champion one PR at a time and we should try to keep
the flow of championed PRs reasonable.</p>
</li>
</ul>
</li>
<li><p>Do not self merge, except for 'small' patches to un-break the CI or
when another reviewer explicitly allows it (ex, "Approve modulo CI
passing, may self merge when green").</p></li>
</ul>
</section>
<sectionid="automated-tests">
<spanid="pr-automated-tests"></span><h3>Automated tests<aclass="headerlink" href="#automated-tests" title="Permalink to this headline">#</a></h3>
<p>Whenever a pull request is created or updated, various automated test tools
will run on all supported platforms and versions of Python.</p>
<ulclass="simple">
<li><p>Make sure the Linting, GitHub Actions, AppVeyor, CircleCI, and Azure
pipelines are passing before merging (All checks are listed at the bottom of
the GitHub page of your pull request). Here are some tips for finding the
cause of the test failure:</p>
<ul>
<li><p>If <em>Linting</em> fails, you have a code style issue, which will be listed
as annotations on the pull request's diff.</p></li>
<li><p>If a GitHub Actions or AppVeyor run fails, search the log for <codeclass="docutils literal notranslate"><spanclass="pre">FAILURES</span></code>.
The subsequent section will contain information on the failed tests.</p></li>
<li><p>If CircleCI fails, likely you have some reStructuredText style issue in
the docs. Search the CircleCI log for <codeclass="docutils literal notranslate"><spanclass="pre">WARNING</span></code>.</p></li>
<li><p>If Azure pipelines fail with an image comparison error, you can find the
images as <em>artifacts</em> of the Azure job:</p>
<ul>
<li><p>Click <em>Details</em> on the check on the GitHub PR page.</p></li>
<li><p>Click <em>View more details on Azure Pipelines</em> to go to Azure.</p></li>
<li><p>On the overview page <em>artifacts</em> are listed in the section <em>Related</em>.</p></li>
</ul>
</li>
</ul>
</li>
<li><p>Codecov and LGTM are currently for information only. Their failure is not
necessarily a blocker.</p></li>
<li><p><aclass="reference external" href="https://tox.readthedocs.io/">tox</a> is not used in the automated testing. It is supported for testing
locally.</p>
</li>
<li><p>If you know your changes do not need to be tested (this is very rare!), all
CIs can be skipped for a given commit by including <codeclass="docutils literal notranslate"><spanclass="pre">[ci</span><spanclass="pre">skip]</span></code> or
<codeclass="docutils literal notranslate"><spanclass="pre">[skip</span><spanclass="pre">ci]</span></code> in the commit message. If you know only a subset of CIs need
to be run (e.g., if you are changing some block of plain reStructuredText and
want only CircleCI to run to render the result), individual CIs can be
skipped on individual commits as well by using the following substrings
<li><p>AppVeyor: <codeclass="docutils literal notranslate"><spanclass="pre">[skip</span><spanclass="pre">appveyor]</span></code> (must be in the first line of the commit)</p></li>
<spanid="pr-squashing"></span><h3>Number of commits and squashing<aclass="headerlink" href="#number-of-commits-and-squashing" title="Permalink to this headline">#</a></h3>
<ulclass="simple">
<li><p>Squashing is case-by-case. The balance is between burden on the
contributor, keeping a relatively clean history, and keeping a
history usable for bisecting. The only time we are really strict
about it is to eliminate binary files (ex multiple test image
re-generations) and to remove upstream merges.</p></li>
<li><p>Do not let perfect be the enemy of the good, particularly for
documentation or example PRs. If you find yourself making many
small suggestions, either open a PR against the original branch,
push changes to the contributor branch, or merge the PR and then
open a new PR against upstream.</p></li>
<li><p>If you push to a contributor branch leave a comment explaining what
you did, ex "I took the liberty of pushing a small clean-up PR to
your branch, thanks for your work.". If you are going to make
substantial changes to the code or intent of the PR please check
with the contributor first.</p></li>
</ul>
</section>
</section>
<sectionid="branches-and-backports">
<spanid="id1"></span><h2>Branches and backports<aclass="headerlink" href="#branches-and-backports" title="Permalink to this headline">#</a></h2>
<sectionid="current-branches">
<h3>Current branches<aclass="headerlink" href="#current-branches" title="Permalink to this headline">#</a></h3>
<p>The current active branches are</p>
<dlclass="simple">
<dt><em>master</em></dt><dd><p>The current development version. Future minor releases (<em>v3.N.0</em>) will be
branched from this. Supports Python 3.7+.</p>
</dd>
<dt><em>v3.N.x</em></dt><dd><p>Maintenance branch for Matplotlib 3.N. Future patch releases will be
branched from this. Supports Python 3.6+.</p>
</dd>
<dt><em>v3.N.M-doc</em></dt><dd><p>Documentation for the current release. On a patch release, this will be
replaced by a properly named branch for the new release.</p>
</dd>
</dl>
</section>
<sectionid="branch-selection-for-pull-requests">
<spanid="pr-branch-selection"></span><h3>Branch selection for pull requests<aclass="headerlink" href="#branch-selection-for-pull-requests" title="Permalink to this headline">#</a></h3>
<p>Generally, all pull requests should target the master branch.</p>
<p>Other branches are fed through <aclass="reference internal" href="#automated-backports"><spanclass="std std-ref">automatic</span></a> or
targeting other branches is only rarely necessary for special maintenance
work.</p>
</section>
<sectionid="backport-strategy">
<h3>Backport strategy<aclass="headerlink" href="#backport-strategy" title="Permalink to this headline">#</a></h3>
<p>We will always backport to the patch release branch (<em>v3.N.x</em>):</p>
<ulclass="simple">
<li><p>critical bug fixes (segfault, failure to import, things that the
user can not work around)</p></li>
<li><p>fixes for regressions against the last two releases.</p></li>
</ul>
<p>Everything else (regressions against older releases, bugs/api
inconsistencies the user can work around in their code) are on a
case-by-case basis, should be low-risk, and need someone to advocate
for and shepherd through the backport.</p>
<p>The only changes to be backported to the documentation branch (<em>v3.N.M-doc</em>)
are changes to <codeclass="file docutils literal notranslate"><spanclass="pre">doc</span></code>, <codeclass="file docutils literal notranslate"><spanclass="pre">examples</span></code>, or <codeclass="file docutils literal notranslate"><spanclass="pre">tutorials</span></code>.
Any changes to <codeclass="file docutils literal notranslate"><spanclass="pre">lib</span></code> or <codeclass="file docutils literal notranslate"><spanclass="pre">src</span></code> including docstring-only changes
should not be backported to this branch.</p>
</section>
<sectionid="automated-backports">
<spanid="id2"></span><h3>Automated backports<aclass="headerlink" href="#automated-backports" title="Permalink to this headline">#</a></h3>
<p>We use meeseeksdev bot to automatically backport merges to the correct
maintenance branch base on the milestone. To work properly the
milestone must be set before merging. If you have commit rights, the
bot can also be manually triggered after a merge by leaving a message
<codeclass="docutils literal notranslate"><spanclass="pre">@meeseeksdev</span><spanclass="pre">backport</span><spanclass="pre">to</span><spanclass="pre">BRANCH</span></code> on the PR. If there are conflicts
meeseekdevs will inform you that the backport needs to be done
manually.</p>
<p>The target branch is configured by putting <codeclass="docutils literal notranslate"><spanclass="pre">on-merge:</span><spanclass="pre">backport</span><spanclass="pre">to</span>
<spanclass="pre">TARGETBRANCH</span></code> in the milestone description on it's own line.</p>
<p>If the bot is not working as expected, please report issues to
<spanid="id3"></span><h3>Manual backports<aclass="headerlink" href="#manual-backports" title="Permalink to this headline">#</a></h3>
<p>When doing backports please copy the form used by meeseekdev,
<codeclass="docutils literal notranslate"><spanclass="pre">Backport</span><spanclass="pre">PR</span><spanclass="pre">#XXXX:</span><spanclass="pre">TITLE</span><spanclass="pre">OF</span><spanclass="pre">PR</span></code>. If you need to manually resolve
conflicts make note of them and how you resolved them in the commit
message.</p>
<p>We do a backport from master to v2.2.x assuming:</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib</span></code> is a read-only remote branch of the matplotlib/matplotlib repo</p></li>
</ul>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">TARGET_SHA</span></code> is the hash of the merge commit you would like to
backport. This can be read off of the GitHub PR page (in the UI with
the merge notification) or through the git CLI tools.</p>
<p>Assuming that you already have a local branch <codeclass="docutils literal notranslate"><spanclass="pre">v2.2.x</span></code> (if not, then
<codeclass="docutils literal notranslate"><spanclass="pre">git</span><spanclass="pre">checkout</span><spanclass="pre">-b</span><spanclass="pre">v2.2.x</span></code>), and that your remote pointing to
<codeclass="docutils literal notranslate"><spanclass="pre">https://github.com/matplotlib/matplotlib</span></code> is called <codeclass="docutils literal notranslate"><spanclass="pre">upstream</span></code>:</p>
<p>Use your discretion to push directly to upstream or to open a PR; be
sure to push or PR against the <codeclass="docutils literal notranslate"><spanclass="pre">v2.2.x</span></code> upstream branch, not <codeclass="docutils literal notranslate"><spanclass="pre">master</span></code>!</p>
</section>
</section>
</section>
</div>
</main>
</div>
</div>
<!-- Scripts loaded after <body> so the DOM is not blocked -->
<divid="unreleased-message"> You are reading an old version of the documentation (v3.5.3). For the latest version see <ahref="https://matplotlib.org/stable/devel/coding_guide.html">https://matplotlib.org/stable/devel/coding_guide.html</a></div>