diff --git a/doc/api/api_changes_3.3/behaviour.rst b/doc/api/api_changes_3.3/behaviour.rst
index b23b136f0d0e..ccdb72e2ec18 100644
--- a/doc/api/api_changes_3.3/behaviour.rst
+++ b/doc/api/api_changes_3.3/behaviour.rst
@@ -274,3 +274,9 @@ instead of ::
# "bar", "barstacked"
# "step", "stepfilled"
+
+Qt and wx backends no longer create a status bar by default
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The coordinates information is now displayed in the toolbar, consistently with
+the other backends. This is intended to simplify embedding of Matplotlib in
+larger GUIs, where Matplotlib may control the toolbar but not the status bar.
diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py
index 6502eadb7d49..1a957b212e96 100644
--- a/lib/matplotlib/backend_bases.py
+++ b/lib/matplotlib/backend_bases.py
@@ -2881,22 +2881,18 @@ def mouse_move(self, event):
except (ValueError, OverflowError):
pass
else:
+ s = s.rstrip()
artists = [a for a in event.inaxes._mouseover_set
if a.contains(event)[0] and a.get_visible()]
-
if artists:
a = cbook._topmost_artist(artists)
if a is not event.inaxes.patch:
data = a.get_cursor_data(event)
if data is not None:
- data_str = a.format_cursor_data(data)
- if data_str is not None:
- s = s + ' ' + data_str
-
- if len(self.mode):
- self.set_message('%s, %s' % (self.mode, s))
- else:
- self.set_message(s)
+ data_str = a.format_cursor_data(data).rstrip()
+ if data_str:
+ s = s + '\n' + data_str
+ self.set_message(s)
else:
self.set_message(self.mode)
diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py
index be18180f8839..c2a7cadf220e 100644
--- a/lib/matplotlib/backends/backend_qt5.py
+++ b/lib/matplotlib/backends/backend_qt5.py
@@ -550,14 +550,12 @@ def __init__(self, canvas, num):
if self.toolbar:
backend_tools.add_tools_to_container(self.toolbar)
self.statusbar = StatusbarQt(self.window, self.toolmanager)
+ sbs_height = self.statusbar.sizeHint().height()
+ else:
+ sbs_height = 0
if self.toolbar is not None:
self.window.addToolBar(self.toolbar)
- if not self.toolmanager:
- # add text label to status bar
- statusbar_label = QtWidgets.QLabel()
- self.window.statusBar().addWidget(statusbar_label)
- self.toolbar.message.connect(statusbar_label.setText)
tbs_height = self.toolbar.sizeHint().height()
else:
tbs_height = 0
@@ -565,8 +563,8 @@ def __init__(self, canvas, num):
# resize the main window so it will display the canvas with the
# requested size:
cs = canvas.sizeHint()
- sbs = self.window.statusBar().sizeHint()
- height = cs.height() + tbs_height + sbs.height()
+ cs_height = cs.height()
+ height = cs_height + tbs_height + sbs_height
self.window.resize(cs.width(), height)
self.window.setCentralWidget(self.canvas)
@@ -599,7 +597,7 @@ def _get_toolbar(self, canvas, parent):
# must be inited after the window, drawingArea and figure
# attrs are set
if matplotlib.rcParams['toolbar'] == 'toolbar2':
- toolbar = NavigationToolbar2QT(canvas, parent, False)
+ toolbar = NavigationToolbar2QT(canvas, parent, True)
elif matplotlib.rcParams['toolbar'] == 'toolmanager':
toolbar = ToolbarQt(self.toolmanager, self.window)
else:
@@ -679,7 +677,7 @@ def __init__(self, canvas, parent, coordinates=True):
if self.coordinates:
self.locLabel = QtWidgets.QLabel("", self)
self.locLabel.setAlignment(
- QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
+ QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.locLabel.setSizePolicy(
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Ignored))
diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py
index a5ab3ca50f97..f57979366130 100644
--- a/lib/matplotlib/backends/backend_wx.py
+++ b/lib/matplotlib/backends/backend_wx.py
@@ -928,13 +928,11 @@ def __init__(self, num, fig):
self.figmgr = FigureManagerWx(self.canvas, num, self)
- statusbar = (StatusbarWx(self, self.toolmanager)
- if self.toolmanager else StatusBarWx(self))
- self.SetStatusBar(statusbar)
self.toolbar = self._get_toolbar()
- if self.toolmanager:
- backend_tools.add_tools_to_manager(self.toolmanager)
+ if self.figmgr.toolmanager:
+ self.SetStatusBar(StatusbarWx(self, self.figmgr.toolmanager))
+ backend_tools.add_tools_to_manager(self.figmgr.toolmanager)
if self.toolbar:
backend_tools.add_tools_to_container(self.toolbar)
@@ -1122,6 +1120,10 @@ def __init__(self, canvas):
self.Bind(wx.EVT_TOOL, getattr(self, callback),
id=self.wx_ids[text])
+ self.AddStretchableSpace()
+ self._label_text = wx.StaticText(self)
+ self.AddControl(self._label_text)
+
self.Realize()
NavigationToolbar2.__init__(self, canvas)
@@ -1300,9 +1302,7 @@ def statbar(self):
return self.GetTopLevelParent().GetStatusBar()
def set_message(self, s):
- status_bar = self.GetTopLevelParent().GetStatusBar()
- if status_bar is not None:
- status_bar.set_function(s)
+ self._label_text.SetLabel(s)
def set_history_buttons(self):
can_backward = self._nav_stack._pos > 0