Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8356fc2

Browse files
committed
Merge pull request #5626 from mdboom/new-icons
ENH: New toolbar icons Conflicts: doc/users/navigation_toolbar.rst - kept new wording lib/matplotlib/backends/backend_qt5.py - wording + indentation change which is now correct
1 parent 077c72e commit 8356fc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3780
-2104
lines changed

doc/_static/toolbar.png

6.32 KB
Loading

doc/users/navigation_toolbar.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ All figure windows come with a navigation toolbar, which can be used
99
to navigate through the data set. Here is a description of each of
1010
the buttons at the bottom of the toolbar
1111

12-
.. image:: ../../lib/matplotlib/mpl-data/images/home.png
12+
.. image:: ../../lib/matplotlib/mpl-data/images/home_large.png
1313

14-
.. image:: ../../lib/matplotlib/mpl-data/images/back.png
14+
.. image:: ../../lib/matplotlib/mpl-data/images/back_large.png
1515

16-
.. image:: ../../lib/matplotlib/mpl-data/images/forward.png
16+
.. image:: ../../lib/matplotlib/mpl-data/images/forward_large.png
1717

1818
The ``Forward`` and ``Back`` buttons
1919
These are akin to the web browser forward and back buttons. They
@@ -26,7 +26,7 @@ The ``Forward`` and ``Back`` buttons
2626
``Back``, think web browser where data views are web pages. Use
2727
the pan and zoom to rectangle to define new views.
2828

29-
.. image:: ../../lib/matplotlib/mpl-data/images/move.png
29+
.. image:: ../../lib/matplotlib/mpl-data/images/move_large.png
3030

3131
The ``Pan/Zoom`` button
3232
This button has two modes: pan and zoom. Click the toolbar button
@@ -50,7 +50,7 @@ The ``Pan/Zoom`` button
5050
mouse button. The radius scale can be zoomed in and out using the
5151
right mouse button.
5252

53-
.. image:: ../../lib/matplotlib/mpl-data/images/zoom_to_rect.png
53+
.. image:: ../../lib/matplotlib/mpl-data/images/zoom_to_rect_large.png
5454

5555
The ``Zoom-to-rectangle`` button
5656
Click this toolbar button to activate this mode. Put your mouse
@@ -61,14 +61,15 @@ The ``Zoom-to-rectangle`` button
6161
with the right button, which will place your entire axes in the
6262
region defined by the zoom out rectangle.
6363

64-
.. image:: ../../lib/matplotlib/mpl-data/images/subplots.png
64+
.. image:: ../../lib/matplotlib/mpl-data/images/subplots_large.png
6565

6666
The ``Subplot-configuration`` button
67-
Use this tool to configure the parameters of the subplot: the
68-
left, right, top, bottom, space between the rows and space between
69-
the columns.
67+
Use this tool to configure the appearance of the subplot:
68+
you can stretch or compress the left, right, top, or bottom
69+
side of the subplot, or the space between the rows or
70+
space between the columns.
7071

71-
.. image:: ../../lib/matplotlib/mpl-data/images/filesave.png
72+
.. image:: ../../lib/matplotlib/mpl-data/images/filesave_large.png
7273

7374
The ``Save`` button
7475
Click this button to launch a file save dialog. You can save
@@ -94,7 +95,7 @@ Zoom-to-rect **o**
9495
Save **ctrl** + **s**
9596
Toggle fullscreen **ctrl** + **f**
9697
Close plot **ctrl** + **w**
97-
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
98+
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
9899
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
99100
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse
100101
Toggle grid **g** when mouse is over an axes
@@ -135,8 +136,3 @@ example code for GTK::
135136

136137
win.show_all()
137138
gtk.main()
138-
139-
140-
141-
142-

examples/pylab_examples/matplotlib_icon.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2732,8 +2732,8 @@ class NavigationToolbar2(object):
27322732
(None, None, None, None),
27332733
('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),
27342734
('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
2735-
(None, None, None, None),
27362735
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
2736+
(None, None, None, None),
27372737
('Save', 'Save the figure', 'filesave', 'save_figure'),
27382738
)
27392739

lib/matplotlib/backend_tools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,7 @@ def _mouse_move(self, event):
870870
"""Default tools"""
871871

872872
default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
873-
['zoompan', ['pan', 'zoom']],
874-
['layout', ['subplots']],
873+
['zoompan', ['pan', 'zoom', 'subplots']],
875874
['io', ['save']]]
876875
"""Default tools in the toolbar"""
877876

lib/matplotlib/backends/backend_qt5.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
except ImportError:
2929
figureoptions = None
3030

31-
from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
31+
from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName,
32+
__version__, is_pyqt5)
3233
from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
3334

3435
backend_version = __version__
@@ -142,6 +143,9 @@ def _create_qApp():
142143
else:
143144
qApp = app
144145

146+
if is_pyqt5():
147+
qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
148+
145149

146150
class Show(ShowBase):
147151
def mainloop(self):
@@ -567,6 +571,8 @@ def __init__(self, canvas, parent, coordinates=True):
567571
NavigationToolbar2.__init__(self, canvas)
568572

569573
def _icon(self, name):
574+
if is_pyqt5():
575+
name = name.replace('.png', '_large.png')
570576
return QtGui.QIcon(os.path.join(self.basedir, name))
571577

572578
def _init_toolbar(self):
@@ -583,11 +589,10 @@ def _init_toolbar(self):
583589
a.setCheckable(True)
584590
if tooltip_text is not None:
585591
a.setToolTip(tooltip_text)
586-
587-
if figureoptions is not None:
588-
a = self.addAction(self._icon("qt4_editor_options.png"),
589-
'Customize', self.edit_parameters)
590-
a.setToolTip('Edit curves line and axes parameters')
592+
if figureoptions is not None and text == 'Subplots':
593+
a = self.addAction(self._icon("qt4_editor_options.png"),
594+
'Customize', self.edit_parameters)
595+
a.setToolTip('Edit axis, curve and image parameters')
591596

592597
self.buttons = {}
593598

@@ -607,6 +612,14 @@ def _init_toolbar(self):
607612
# reference holder for subplots_adjust window
608613
self.adj_window = None
609614

615+
# Esthetic adjustments - we need to set these explicitly in PyQt5
616+
# otherwise the layout looks different - but we don't want to set it if
617+
# not using HiDPI icons otherwise they look worse than before.
618+
if is_pyqt5():
619+
self.setIconSize(QtCore.QSize(24, 24))
620+
self.layout().setSpacing(12)
621+
self.setMinimumHeight(48)
622+
610623
if figureoptions is not None:
611624
def edit_parameters(self):
612625
allaxes = self.canvas.figure.get_axes()

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def new_figure_manager_given_figure(num, figure):
9797
# doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto
9898
# command which we call directly. Source:
9999
# http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
100-
icon_fname = os.path.join(rcParams['datapath'], 'images', 'matplotlib.gif')
100+
icon_fname = os.path.join(rcParams['datapath'], 'images', 'matplotlib.ppm')
101101
icon_img = Tk.PhotoImage(file=icon_fname)
102102
try:
103103
window.tk.call('wm', 'iconphoto', window._w, icon_img)

lib/matplotlib/backends/qt_compat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,7 @@ def _getSaveFileName(*args, **kwargs):
192192
193193
'''
194194
QtWidgets = QtGui
195+
196+
197+
def is_pyqt5():
198+
return QT_API == QT_API_PYQT5
-2.89 KB
Binary file not shown.
-1.06 KB
Loading
0 Bytes
Binary file not shown.
Lines changed: 46 additions & 63 deletions
Loading
620 Bytes
Loading
6.76 KB
Binary file not shown.
-8.46 KB
Binary file not shown.
-663 Bytes
Loading
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)