Skip to content

Commit eaaee4e

Browse files
committed
Fix loading user-defined icons for Qt plot window
1 parent 04834bc commit eaaee4e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/backends/backend_qt.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,14 @@ def _icon(self, name):
682682
Construct a `.QIcon` from an image file *name*, including the extension
683683
and relative to Matplotlib's "images" data directory.
684684
"""
685-
name = name.replace('.png', '_large.png')
686-
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
685+
# use a high-resolution icon with suffix '_large' if available
686+
# note: user-provided icons may not have '_large' versions
687+
path_regular = cbook._get_data_path('images', name)
688+
path_large = path_regular.with_name(
689+
path_regular.name.replace('.png', '_large.png'))
690+
filename = str(path_large if path_large.exists() else path_regular)
691+
692+
pm = QtGui.QPixmap(filename)
687693
_setDevicePixelRatio(pm, _devicePixelRatioF(self))
688694
if self.palette().color(self.backgroundRole()).value() < 128:
689695
icon_color = self.palette().color(self.foregroundRole())

0 commit comments

Comments
 (0)