diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 5fa8353880c0..484b6282b388 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -28,7 +28,8 @@ except ImportError: figureoptions = None -from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__ +from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName, + __version__, is_pyqt5) from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool backend_version = __version__ @@ -142,6 +143,9 @@ def _create_qApp(): else: qApp = app + if is_pyqt5(): + qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) + class Show(ShowBase): def mainloop(self): @@ -566,6 +570,8 @@ def __init__(self, canvas, parent, coordinates=True): NavigationToolbar2.__init__(self, canvas) def _icon(self, name): + if is_pyqt5(): + name = name.replace('.png', '_hidpi.png') return QtGui.QIcon(os.path.join(self.basedir, name)) def _init_toolbar(self): @@ -606,6 +612,14 @@ def _init_toolbar(self): # reference holder for subplots_adjust window self.adj_window = None + # Esthetic adjustments - we need to set these explicitly in PyQt5 + # otherwise the layout looks different - but we don't want to set it if + # not using HiDPI icons otherwise they look worse than before. + if is_pyqt5(): + self.setIconSize(QtCore.QSize(24, 24)) + self.layout().setSpacing(12) + self.setMinimumHeight(48) + if figureoptions is not None: def edit_parameters(self): allaxes = self.canvas.figure.get_axes() diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index f237d449eb20..307fb81453a9 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -150,3 +150,7 @@ def _getSaveFileName(*args, **kwargs): ''' QtWidgets = QtGui + + +def is_pyqt5(): + return QT_API == QT_API_PYQT5 diff --git a/lib/matplotlib/mpl-data/images/back_hidpi.png b/lib/matplotlib/mpl-data/images/back_hidpi.png new file mode 100644 index 000000000000..7755db11a546 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/back_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/filesave_hidpi.png b/lib/matplotlib/mpl-data/images/filesave_hidpi.png new file mode 100644 index 000000000000..8980a2cb14a4 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/filesave_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/forward_hidpi.png b/lib/matplotlib/mpl-data/images/forward_hidpi.png new file mode 100644 index 000000000000..b02047e98d9b Binary files /dev/null and b/lib/matplotlib/mpl-data/images/forward_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/hand_hidpi.png b/lib/matplotlib/mpl-data/images/hand_hidpi.png new file mode 100644 index 000000000000..35ec95185a96 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/hand_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/home_hidpi.png b/lib/matplotlib/mpl-data/images/home_hidpi.png new file mode 100644 index 000000000000..cf76bdade116 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/home_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/matplotlib_hidpi.png b/lib/matplotlib/mpl-data/images/matplotlib_hidpi.png new file mode 100644 index 000000000000..2a0502eacd1a Binary files /dev/null and b/lib/matplotlib/mpl-data/images/matplotlib_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/move_hidpi.png b/lib/matplotlib/mpl-data/images/move_hidpi.png new file mode 100644 index 000000000000..1317787febff Binary files /dev/null and b/lib/matplotlib/mpl-data/images/move_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/qt4_editor_options_hidpi.png b/lib/matplotlib/mpl-data/images/qt4_editor_options_hidpi.png new file mode 100644 index 000000000000..956b3baa77e0 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/qt4_editor_options_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/subplots_hidpi.png b/lib/matplotlib/mpl-data/images/subplots_hidpi.png new file mode 100644 index 000000000000..63be0266cd72 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/subplots_hidpi.png differ diff --git a/lib/matplotlib/mpl-data/images/zoom_to_rect_hidpi.png b/lib/matplotlib/mpl-data/images/zoom_to_rect_hidpi.png new file mode 100644 index 000000000000..0778cef8b9c0 Binary files /dev/null and b/lib/matplotlib/mpl-data/images/zoom_to_rect_hidpi.png differ