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

Skip to content

Overview of Axes creation methods #17376

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

Open
timhoffm opened this issue May 10, 2020 · 7 comments · May be fixed by #26417
Open

Overview of Axes creation methods #17376

timhoffm opened this issue May 10, 2020 · 7 comments · May be fixed by #26417
Labels
Documentation keep Items to be ignored by the “Stale” Github Action

Comments

@timhoffm
Copy link
Member

We should have an overview (possibly in the tutorials) which methods create Axes and when to use which.

This could contain the flow-chart blow plus additional descriptions.

  • I've not taken into account subgridspec and axes_grid1.
  • Am I missing some methods?
  • the diagram could be embedded using .. graphviz. However, while it renders with http://graphviz.it/ it currently does not with sphinx (issueing some errors).
  • The styling could still be improved (add links, font/color, use a HTML node instead of a record, ...)

grafik

digraph {
    node[shape=diamond]
        q_fullsize; q_simple_grid; q_complex_grid; q_inset; q_twin;
    node[shape=record]
        full_size;
       
    q_fullsize [label="full size?"]
    full_size [label="{plt.subplot()|plt.subplots()} | {Figure.add_subplot()|Figure.subplots()}"]
    q_simple_grid [label="simple grid?"]
    simple_grid [label="{plt.subplot(n, m, k) | plt.subplots(n, m)}| {Figure.add_subplot(n, m, k) | Figure.subplots(n, m)}"]
    q_complex_grid [label="complex grid?"]
    complex_grid [label="{plt.subplot2grid() | plt.subplot(subplotspec) | plt.subplots(gridspec_kw) | } | { | Figure.subplot(subplotspec) | Figure.subplots(gridspec_kw) | GridSpec.subplots()}"]
    q_inset [label="inset?"]
    inset [label="Axes.inset_axes()"]
    q_twin [label="twin?"]
    twin [label="{plt.twinx() | plt.twiny()} | {Axes.twinx() | Axes.twiny()}"]
    axes [label="{plt.axes() | Figure.add_axes()}"]

    q_fullsize -> q_simple_grid [ label = "No" ];
    q_simple_grid -> q_complex_grid [label = "No" ];
    q_fullsize -> full_size [ label = "Yes" ];
    q_simple_grid -> simple_grid[ label = "Yes" ];
    q_complex_grid -> complex_grid [label = "Yes"];
    q_complex_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_simple_grid simple_grid
    }
    {
        rank=same;
        q_complex_grid complex_grid
    }
    {
        rank=same;
        q_inset inset
    }
    {
        rank=same;
        q_twin twin
    }
}
@ianhi
Copy link
Contributor

ianhi commented May 10, 2020

This would be great! I've always been a bit overwhelmed by this.

possibly in the tutorials

👍

Am I missing some methods?

I think you're missing Figure.gca() which will create an axis if one doesn't exist. https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.gca

Suggestions:

  • Are there any methods to create axes that shouldn't be used? If so it would great to have this communicated.
  • It would also be great to have some substructure at each level to avoid choice paralysis. Something like highlighting one in green for each box of methods as the first thing someone should consider.
  • How about providing some basic imagery demonstrating the types of layouts being made on each level. Even just some arrays of squares with ellipses.

@YonghuiWang99
Copy link

I am just learning matplotlib through the tutorials. The overview helps me to understand more about the creative logic. Understanding improve skill of application, I believe. So thank you.

In addition, do you think if it is possible to add general concepts which I could find in version 3.1.0 in the current released version (version 3.2.1) ? I think it is also important to understand the creative logic as well.

https://matplotlib.org/3.1.0/tutorials/introductory/usage.html

@timhoffm timhoffm mentioned this issue May 26, 2020
13 tasks
@story645 story645 pinned this issue May 26, 2020
@story645 story645 unpinned this issue May 26, 2020
@timhoffm
Copy link
Member Author

  • added subplot_mosaic
  • style updates

grafik

digraph {
    node[shape=diamond, width=2.7, height=0.8]
        q_fullsize; q_simple_grid; q_complex_grid; q_inset; q_twin;
    node[shape=none, margin=0]
        full_size;
       
    q_fullsize [label="full size?"]
    full_size [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">plt.subplot()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Figure.add_subplot()</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">plt.subplots()</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplots()</TD></TR>
</TABLE></FONT>>]
    q_simple_grid [label="simple grid?"]
    simple_grid [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">plt.subplot(n, m, k)</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Figure.add_subplot(n, m, k)</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left">plt.subplots(n, m)</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplots(n, m)</TD></TR>
</TABLE></FONT>>]
    q_complex_grid [label="complex grid?"]
    complex_grid [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">plt.subplot_mosaic()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Figure.subplot_mosaic()</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left">plt.subplot2grid()</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplot(subplotspec)</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left">plt.subplot(subplotspec)</TD><TD BGCOLOR="gray90" ALIGN="left">Figure.subplots(gridspec_kw)</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left">plt.subplots(gridspec_kw)</TD><TD BGCOLOR="gray90" ALIGN="left">GridSpec.subplots()</TD></TR>
</TABLE></FONT>>]
    q_inset [label="inset?"]
    inset [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5" ALIGN="left">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Axes.inset_axes()</TD></TR>
</TABLE></FONT>>]
    q_twin [label="twin?"]
    twin [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">plt.twinx()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="200">Axes.twinx()</TD></TR>
<TR><TD BGCOLOR="gray90" ALIGN="left">plt.twiny()</TD><TD BGCOLOR="gray90" ALIGN="left">Axes.twiny()</TD></TR>
</TABLE></FONT>>]
    axes [label=<
<FONT FACE="arial"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="2" CELLPADDING="5">
<TR><TD BGCOLOR="gray90" ALIGN="left" WIDTH="150">plt.axes()</TD><TD BGCOLOR="gray90" ALIGN="left" WIDTH="150">Figure.add_axes()</TD></TR>
</TABLE></FONT>>]

    q_fullsize -> q_simple_grid [ label = "No" ];
    q_simple_grid -> q_complex_grid [label = "No" ];
    q_fullsize -> full_size [ label = "Yes" ];
    q_simple_grid -> simple_grid[ label = "Yes" ];
    q_complex_grid -> complex_grid [label = "Yes"];
    q_complex_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_simple_grid simple_grid
    }
    {
        rank=same;
        q_complex_grid complex_grid
    }
    {
        rank=same;
        q_inset inset
    }
    {
        rank=same;
        q_twin twin
    }
}

@QuLogic
Copy link
Member

QuLogic commented Aug 30, 2021

You can insert Graphviz diagrams into Sphinx; maybe you just want to copy what you have in directly somewhere?

@timhoffm
Copy link
Member Author

That's the plan. When trying that last year, it did not compile; see the original post. Should be tried again, but I don't have the time to work on this currently. Anybody is welcome to turn this in to a proper PR. But maybe it's better to wait until the new documentation structure is merged to see where in the docs this should go.

timhoffm added a commit to timhoffm/matplotlib that referenced this issue Jul 30, 2023
Closes matplotlib#17376.

There might still be room for further improvements, be it description
or formatting. But I would like to leave that for later. The main goal
is to get a first version of this in soon.
@timhoffm timhoffm linked a pull request Jul 30, 2023 that will close this issue
timhoffm added a commit to timhoffm/matplotlib that referenced this issue Jul 30, 2023
Closes matplotlib#17376.

There might still be room for further improvements, be it description
or formatting. But I would like to leave that for later. The main goal
is to get a first version of this in soon.
timhoffm added a commit to timhoffm/matplotlib that referenced this issue Jul 31, 2023
Closes matplotlib#17376.

There might still be room for further improvements, be it description
or formatting. But I would like to leave that for later. The main goal
is to get a first version of this in soon.
timhoffm added a commit to timhoffm/matplotlib that referenced this issue Jul 31, 2023
Closes matplotlib#17376.

There might still be room for further improvements, be it description
or formatting. But I would like to leave that for later. The main goal
is to get a first version of this in soon.
@github-actions
Copy link

github-actions bot commented Aug 2, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Aug 2, 2023
@QuLogic
Copy link
Member

QuLogic commented Aug 2, 2023

The PR has been opened; ergo this issue can stay open.

@QuLogic QuLogic added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation keep Items to be ignored by the “Stale” Github Action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants