Skip to content
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

Improve Axes selection in Qt figure options. #13375

Merged
merged 1 commit into from
Feb 19, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 6, 2019

  1. Make sure Axes "labels" in the input dialog are unique
    (QInputDialog.getItem returns the selected string, but we'll get the
    wrong index if two axes share e.g. the same title), by including the
    axes id() if necessary; conversely, don't include the id() in the
    user-facing UI unless necessary.

    For example, previously, after

    fig, axs = plt.subplots(2)
    axs[0].set(xlabel="foo"); axs[1].set(xlabel="foo")
    

    the input dialog would not allow selecting the second axes.

  2. If the Axes artist has a "label" attached to it (per
    Artist.set_label), use it in priority for the input dialog.
    Normally, axes labels are not used (they are used for other artists
    for the legend, for example). This change allows us to attach a
    "(colorbar)" label to colorbar axes, which makes it easier to select
    the right axes.

    After

     fig, axs = plt.subplots(2)
     axs[0].imshow([[0]]); fig.colorbar(axs[0].images[0])
     axs[1].imshow([[0]]); fig.colorbar(axs[1].images[0])
    

    previously the input dialog would have the entries

     <anonymous AxesSubplot (id: 0x...)>
     <anonymous AxesSubplot (id: 0x...)>
     <anonymous AxesSubplot (id: 0x...)>
     <anonymous AxesSubplot (id: 0x...)>
    

    but now it has the entries

     <anonymous AxesSubplot> (id: 0x...)
     <anonymous AxesSubplot> (id: 0x...)
     (colorbar) (id: 0x...)
     (colorbar) (id: 0x...)
    

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added the GUI: Qt label Feb 6, 2019
lib/matplotlib/colorbar.py Outdated Show resolved Hide resolved
@tacaswell tacaswell added this to the v3.1.0 milestone Feb 6, 2019
1. Make sure Axes "labels" in the input dialog are unique
   (QInputDialog.getItem returns the selected string, but we'll get the
   wrong index if two axes share e.g. the same title), by including the
   axes id() if necessary; conversely, don't include the id() in the
   user-facing UI unless necessary.

   For example, previously, after

       fig, axs = plt.subplots(2)
       axs[0].set(xlabel="foo"); axs[1].set(xlabel="foo")

   the input dialog would not allow selecting the second axes.

2. If the Axes artist has a "label" attached to it (per
   `Artist.set_label`), use it in priority for the input dialog.
   Normally, axes labels are not used (they are used for other artists
   for the legend, for example).  This change allows us to attach a
   "(colorbar)" label to colorbar axes, which makes it easier to select
   the right axes.

   After

        fig, axs = plt.subplots(2)
        axs[0].imshow([[0]]); fig.colorbar(axs[0].images[0])
        axs[1].imshow([[0]]); fig.colorbar(axs[1].images[0])

    previously the input dialog would have the entries

        <anonymous AxesSubplot (id: 0x...)>
        <anonymous AxesSubplot (id: 0x...)>
        <anonymous AxesSubplot (id: 0x...)>
        <anonymous AxesSubplot (id: 0x...)>

    but now it has the entries

        <anonymous AxesSubplot> (id: 0x...)
        <anonymous AxesSubplot> (id: 0x...)
        (colorbar) (id: 0x...)
        (colorbar) (id: 0x...)
@jklymak
Copy link
Member

jklymak commented Feb 7, 2019

Wow, who knew axes had labels. What are they used for (other than whatever you mean by "Axes selecton in Qt figures")?

@anntzer
Copy link
Contributor Author

anntzer commented Feb 7, 2019

Probably nothing (well, they're artists and all artists have labels as that's defined in the base class).

What I meant by "Axes selection in Qt figure options" is
screenshot

@dstansby dstansby merged commit e22f6e8 into matplotlib:master Feb 19, 2019
@anntzer anntzer deleted the figureoptions branch February 19, 2019 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants