Skip to content

Commit d6ce8e5

Browse files
committed
matplotlibrc path search fix
1 parent 69a9811 commit d6ce8e5

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ def get_cachedir():
589589
@_logged_cached('matplotlib data path: %s')
590590
def get_data_path():
591591
"""Return the path to Matplotlib data."""
592-
return str(Path(__file__).with_name("mpl-data"))
592+
return str(Path(__file__).parent.parent.parent.parent.parent /
593+
'share/matplotlib/mpl-data')
593594

594595

595596
def matplotlib_fname():
@@ -609,6 +610,7 @@ def matplotlib_fname():
609610
is not defined)
610611
- On other platforms,
611612
- ``$HOME/.matplotlib/matplotlibrc`` if ``$HOME`` is defined
613+
- ``/etc/matplotlibrc``
612614
- Lastly, it looks in ``$MATPLOTLIBDATA/matplotlibrc``, which should always
613615
exist.
614616
"""
@@ -627,6 +629,7 @@ def gen_candidates():
627629
yield matplotlibrc
628630
yield os.path.join(matplotlibrc, 'matplotlibrc')
629631
yield os.path.join(get_configdir(), 'matplotlibrc')
632+
yield '/etc/matplotlibrc'
630633
yield os.path.join(get_data_path(), 'matplotlibrc')
631634

632635
for fname in gen_candidates():

lib/matplotlib/backend_tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class ToolHome(ViewsPositionsBase):
605605
"""Restore the original view limits."""
606606

607607
description = 'Reset original view'
608-
image = 'mpl-data/images/home'
608+
image = '/usr/share/matplotlib/mpl-data/images/home'
609609
default_keymap = property(lambda self: mpl.rcParams['keymap.home'])
610610
_on_trigger = 'home'
611611

@@ -614,7 +614,7 @@ class ToolBack(ViewsPositionsBase):
614614
"""Move back up the view limits stack."""
615615

616616
description = 'Back to previous view'
617-
image = 'mpl-data/images/back'
617+
image = '/usr/share/matplotlib/mpl-data/images/back'
618618
default_keymap = property(lambda self: mpl.rcParams['keymap.back'])
619619
_on_trigger = 'back'
620620

@@ -623,7 +623,7 @@ class ToolForward(ViewsPositionsBase):
623623
"""Move forward in the view lim stack."""
624624

625625
description = 'Forward to next view'
626-
image = 'mpl-data/images/forward'
626+
image = '/usr/share/matplotlib/mpl-data/images/forward'
627627
default_keymap = property(lambda self: mpl.rcParams['keymap.forward'])
628628
_on_trigger = 'forward'
629629

@@ -632,14 +632,14 @@ class ConfigureSubplotsBase(ToolBase):
632632
"""Base tool for the configuration of subplots."""
633633

634634
description = 'Configure subplots'
635-
image = 'mpl-data/images/subplots'
635+
image = '/usr/share/matplotlib/mpl-data/images/subplots'
636636

637637

638638
class SaveFigureBase(ToolBase):
639639
"""Base tool for figure saving."""
640640

641641
description = 'Save the figure'
642-
image = 'mpl-data/images/filesave'
642+
image = '/usr/share/matplotlib/mpl-data/images/filesave'
643643
default_keymap = property(lambda self: mpl.rcParams['keymap.save'])
644644

645645

@@ -714,7 +714,7 @@ class ToolZoom(ZoomPanBase):
714714
"""A Tool for zooming using a rectangle selector."""
715715

716716
description = 'Zoom to rectangle'
717-
image = 'mpl-data/images/zoom_to_rect'
717+
image = '/usr/share/matplotlib/mpl-data/images/zoom_to_rect'
718718
default_keymap = property(lambda self: mpl.rcParams['keymap.zoom'])
719719
cursor = cursors.SELECT_REGION
720720
radio_group = 'default'
@@ -836,7 +836,7 @@ class ToolPan(ZoomPanBase):
836836

837837
default_keymap = property(lambda self: mpl.rcParams['keymap.pan'])
838838
description = 'Pan axes with left mouse, zoom with right'
839-
image = 'mpl-data/images/move'
839+
image = '/usr/share/matplotlib/mpl-data/images/move'
840840
cursor = cursors.MOVE
841841
radio_group = 'default'
842842

@@ -900,7 +900,7 @@ def _mouse_move(self, event):
900900
class ToolHelpBase(ToolBase):
901901
description = 'Print tool list, shortcuts and description'
902902
default_keymap = property(lambda self: mpl.rcParams['keymap.help'])
903-
image = 'mpl-data/images/help'
903+
image = '/usr/share/matplotlib/mpl-data/images/help'
904904

905905
@staticmethod
906906
def format_shortcut(key_sequence):

0 commit comments

Comments
 (0)