Skip to content

I'd like to see axes.get_label() when clicking on 'Edit curves lines and axes parameters' after plt.show() #2593

Closed

Description

@rtrwalker

when I do plt.show() on some plot and then click on 'Edit curves lines and axes parameters' button, I'd like to see the label I've applied using ax.set_label('my_label'). Digging around in matplotlib\backends\backend_qt4.py. I found the following code as part of the NavigationToolbar2QT class:

                    title = axes.get_title()
                    ylabel = axes.get_ylabel()
                    if title:
                        fmt = "%(title)s"
                        if ylabel:
                            fmt += ": %(ylabel)s"
                        fmt += " (%(axes_repr)s)"
                    elif ylabel:
                        fmt = "%(axes_repr)s (%(ylabel)s)"
                    else:
                        fmt = "%(axes_repr)s"
                    titles.append(fmt % dict(title = title,
                                         ylabel = ylabel,
                                         axes_repr = repr(axes)))

Could an extra elif be added? It would only kick it if there was no title and no ylabel:

                    title = axes.get_title()
                    ylabel = axes.get_ylabel()
                    label = axes.get_label()
                    if title:
                        fmt = "%(title)s"
                        if ylabel:
                            fmt += ": %(ylabel)s"
                        fmt += " (%(axes_repr)s)"
                    elif ylabel:
                        fmt = "%(axes_repr)s (%(ylabel)s)"
                    elif label:
                        fmt = "%(axes_repr)s (%(label)s)"
                    else:
                        fmt = "%(axes_repr)s"
                    titles.append(fmt % dict(title = title,
                                         ylabel = ylabel, label=label
                                         axes_repr = repr(axes)))

Activity

  1. tacaswell commented on Nov 15, 2013

    @tacaswell
    Member

    can you put that in a pull request?

  2. twmr commented on Nov 15, 2013

    @twmr
    Contributor

    This could be integrated in #2112

  3. tacaswell commented on Nov 15, 2013

    @tacaswell
    Member

    I think there is a preference for more smaller PRs. The smaller the changes, the easier it is to review.

  4. pelson commented on Dec 5, 2013

    @pelson
    Member

    Sounds like a good idea @rtrwalker. I'm going to close the issue in the hope that you will submit a PR which I will happily merge.

    Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions