Skip to content

Commit d981e2b

Browse files
committed
Nicer axes names in selector for figure options.
Replace the old label, which included the legthy repr of the axes object, to a nicer label which emphasizes the title or axes labels (depending on what is present). Also drops the use of the label of the Axes object itself, for which I haven't found any other reference or use in general. (Another option would be to use solely `Axes.get_label()` when defined, as this doesn't seem to have any other use.) See #5468.
1 parent a56d588 commit d981e2b

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

lib/matplotlib/backends/backend_qt5.py

+6-17
Original file line numberDiff line numberDiff line change
@@ -618,23 +618,12 @@ def edit_parameters(self):
618618
else:
619619
titles = []
620620
for axes in allaxes:
621-
title = axes.get_title()
622-
ylabel = axes.get_ylabel()
623-
label = axes.get_label()
624-
if title:
625-
fmt = "%(title)s"
626-
if ylabel:
627-
fmt += ": %(ylabel)s"
628-
fmt += " (%(axes_repr)s)"
629-
elif ylabel:
630-
fmt = "%(axes_repr)s (%(ylabel)s)"
631-
elif label:
632-
fmt = "%(axes_repr)s (%(label)s)"
633-
else:
634-
fmt = "%(axes_repr)s"
635-
titles.append(fmt % dict(title=title,
636-
ylabel=ylabel, label=label,
637-
axes_repr=repr(axes)))
621+
name = (axes.get_title() or
622+
" - ".join(filter(None, [axes.get_xlabel(),
623+
axes.get_ylabel()])) or
624+
"<anonymous {} (id: {:#x})>".format(
625+
type(axes).__name__, id(axes)))
626+
titles.append(name)
638627
item, ok = QtWidgets.QInputDialog.getItem(
639628
self.parent, 'Customize', 'Select axes:', titles, 0, False)
640629
if ok:

0 commit comments

Comments
 (0)