diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index d6b3e9f9f0ba..f1966b1848c9 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -758,30 +758,31 @@ def sizeHint(self): return size def edit_parameters(self): - allaxes = self.canvas.figure.get_axes() - if not allaxes: + axes = self.canvas.figure.get_axes() + if not axes: QtWidgets.QMessageBox.warning( self.parent, "Error", "There are no axes to edit.") return - elif len(allaxes) == 1: - axes, = allaxes + elif len(axes) == 1: + ax, = axes else: - titles = [] - for axes in allaxes: - name = (axes.get_title() or - " - ".join(filter(None, [axes.get_xlabel(), - axes.get_ylabel()])) or - "".format( - type(axes).__name__, id(axes))) - titles.append(name) + titles = [ + ax.get_label() or + ax.get_title() or + " - ".join(filter(None, [ax.get_xlabel(), ax.get_ylabel()])) or + f"" + for ax in axes] + duplicate_titles = [ + title for title in titles if titles.count(title) > 1] + for i, ax in enumerate(axes): + if titles[i] in duplicate_titles: + titles[i] += f" (id: {id(ax):#x})" # Deduplicate titles. item, ok = QtWidgets.QInputDialog.getItem( self.parent, 'Customize', 'Select axes:', titles, 0, False) - if ok: - axes = allaxes[titles.index(item)] - else: + if not ok: return - - figureoptions.figure_edit(axes, self) + ax = axes[titles.index(item)] + figureoptions.figure_edit(ax, self) def _update_buttons_checked(self): # sync button checkstates to match active mode diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 712b8843ed9e..e6b640e017ba 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -1437,7 +1437,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15, if parent_anchor is not False: ax.set_anchor(parent_anchor) - cax = fig.add_axes(pbcb) + cax = fig.add_axes(pbcb, label="") # OK, now make a layoutbox for the cb axis. Later, we will use this # to make the colorbar fit nicely. @@ -1551,7 +1551,7 @@ def make_axes_gridspec(parent, *, fraction=0.15, shrink=1.0, aspect=20, **kw): parent.set_anchor(panchor) fig = parent.get_figure() - cax = fig.add_subplot(gs2[1]) + cax = fig.add_subplot(gs2[1], label="") cax.set_aspect(aspect, anchor=anchor, adjustable='box') return cax, kw