Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Add overview of axes creation methods #26417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions galleries/users_explain/axes/axes_creation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#################################
Overview of Axes creation methods
#################################

Depending on the use case, different methods for creating an Axes are most useful.
The following diagram gives an overview by characterizing the desired Axes.

Additionally, most of the methods come in two flavors: A `.pyplot` function and a
method on a `.Figure` or `~.axes.Axes`.

``plt.subplots()`` and ``plt.subplot_mosaic()`` return a Figure and one or more Axes.
They are the most common stating points for a Matplotlib plot. All other methods
only return an Axes.

.. graphviz::

digraph {
node[shape=diamond, width=2.7, height=0.8]
q_fullsize; q_regular_grid; q_general_grid; q_inset; q_twin;
node[shape=none, margin=0]
full_size;

legend [label=<
<FONT FACE="helvetica-bold"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200">pyplot functions</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Figure/Axes methods</TD></TR>
<TR><TD BGCOLOR="white" ALIGN="left" WIDTH="200"><FONT FACE="helvetica" COLOR="gray50">less used variants</FONT></TD></TR>
</TABLE></FONT>>]


q_fullsize [label="full size?"]
full_size [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200">plt.subplots()</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplots()</TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200"><FONT COLOR="gray50">plt.subplot()</FONT></TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200"><FONT COLOR="gray50">Figure.add_subplot()</FONT></TD></TR>
</TABLE></FONT>>]
q_regular_grid [label="regular grid?"]
regular_grid [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left">plt.subplots(n, m)</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplots(n, m)</TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200"><FONT COLOR="gray50">plt.subplot(n, m, k)</FONT></TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200"><FONT COLOR="gray50">Figure.add_subplot(n, m, k)</FONT></TD></TR>
</TABLE></FONT>>]
q_general_grid [label="general grid?"]
general_grid [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200">plt.subplot_mosaic()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Figure.subplot_mosaic()</TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left"><FONT COLOR="gray50">plt.subplot2grid()</FONT></TD><TD BGCOLOR="gray90" ALIGN="left"><FONT COLOR="gray50">GridSpec.subplots()</FONT></TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left"><FONT COLOR="gray50">plt.subplots(gridspec_kw)</FONT></TD><TD BGCOLOR="gray90" ALIGN="left"><FONT COLOR="gray50">Figure.subplots(gridspec_kw)</FONT></TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left"><FONT COLOR="gray50">plt.subplot(subplotspec)</FONT></TD><TD BGCOLOR="gray90" ALIGN="left"><FONT COLOR="gray50">Figure.subplot(subplotspec)</FONT></TD></TR>
</TABLE></FONT>>]
q_inset [label="inset?"]
inset [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5" ALIGN="left">
<TR><TD BGCOLOR="white" ALIGN="left" WIDTH="200"></TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Axes.inset_axes()</TD></TR>
</TABLE></FONT>>]
q_twin [label="twin?"]
twin [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="200">plt.twinx()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Axes.twinx()</TD></TR>
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left">plt.twiny()</TD><TD BGCOLOR="gray90" ALIGN="left">Axes.twiny()</TD></TR>
</TABLE></FONT>>]
axes [label=<
<FONT FACE="helvetica"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="#C5E5F7" ALIGN="left" WIDTH="150">plt.axes()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="150">Figure.add_axes()</TD></TR>
</TABLE></FONT>>]

legend -> full_size [ style = invis ];

q_fullsize -> q_regular_grid [ label = "No" ];
q_regular_grid -> q_general_grid [label = "No" ];
q_fullsize -> full_size [ label = "Yes" ];
q_regular_grid -> regular_grid[ label = "Yes" ];
q_general_grid -> general_grid [label = "Yes"];
q_general_grid -> q_inset [label = "No"];
q_inset -> inset[label="Yes"];
q_inset -> q_twin [label="No"]
q_twin -> twin[label="Yes"]
q_twin -> axes[label="No"]

{
rank=same;
q_fullsize full_size
}
{
rank=same;
q_regular_grid regular_grid
}
{
rank=same;
q_general_grid general_grid
}
{
rank=same;
q_inset inset
}
{
rank=same;
q_twin twin
}
}
2 changes: 2 additions & 0 deletions galleries/users_explain/axes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ annotations like x- and y-labels, titles, and legends.
:maxdepth: 2

axes_intro
axes_creation


.. toctree::
:maxdepth: 1
Expand Down