Skip to content

Commit ed6c1cf

Browse files
committed
matplotlibrc path search fix
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent 5cd38c3 commit ed6c1cf

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/matplotlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ def get_cachedir():
593593
@_logged_cached('matplotlib data path: %s')
594594
def get_data_path():
595595
"""Return the path to Matplotlib data."""
596-
return str(Path(__file__).with_name("mpl-data"))
596+
return str(Path(__file__).parent.parent.parent.parent.parent /
597+
'share/matplotlib/mpl-data')
597598

598599

599600
def matplotlib_fname():
@@ -613,6 +614,7 @@ def matplotlib_fname():
613614
is not defined)
614615
- On other platforms,
615616
- ``$HOME/.matplotlib/matplotlibrc`` if ``$HOME`` is defined
617+
- ``/etc/matplotlibrc``
616618
- Lastly, it looks in ``$MATPLOTLIBDATA/matplotlibrc``, which should always
617619
exist.
618620
"""
@@ -631,6 +633,7 @@ def gen_candidates():
631633
yield matplotlibrc
632634
yield os.path.join(matplotlibrc, 'matplotlibrc')
633635
yield os.path.join(get_configdir(), 'matplotlibrc')
636+
yield '/etc/matplotlibrc'
634637
yield os.path.join(get_data_path(), 'matplotlibrc')
635638

636639
for fname in gen_candidates():

lib/matplotlib/backend_tools.py

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

598598
description = 'Reset original view'
599-
image = 'mpl-data/images/home'
599+
image = '/usr/share/matplotlib/mpl-data/images/home'
600600
default_keymap = property(lambda self: mpl.rcParams['keymap.home'])
601601
_on_trigger = 'home'
602602

@@ -605,7 +605,7 @@ class ToolBack(ViewsPositionsBase):
605605
"""Move back up the view limits stack."""
606606

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

@@ -614,7 +614,7 @@ class ToolForward(ViewsPositionsBase):
614614
"""Move forward in the view lim stack."""
615615

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

@@ -623,14 +623,14 @@ class ConfigureSubplotsBase(ToolBase):
623623
"""Base tool for the configuration of subplots."""
624624

625625
description = 'Configure subplots'
626-
image = 'mpl-data/images/subplots'
626+
image = '/usr/share/matplotlib/mpl-data/images/subplots'
627627

628628

629629
class SaveFigureBase(ToolBase):
630630
"""Base tool for figure saving."""
631631

632632
description = 'Save the figure'
633-
image = 'mpl-data/images/filesave'
633+
image = '/usr/share/matplotlib/mpl-data/images/filesave'
634634
default_keymap = property(lambda self: mpl.rcParams['keymap.save'])
635635

636636

@@ -705,7 +705,7 @@ class ToolZoom(ZoomPanBase):
705705
"""A Tool for zooming using a rectangle selector."""
706706

707707
description = 'Zoom to rectangle'
708-
image = 'mpl-data/images/zoom_to_rect'
708+
image = '/usr/share/matplotlib/mpl-data/images/zoom_to_rect'
709709
default_keymap = property(lambda self: mpl.rcParams['keymap.zoom'])
710710
cursor = cursors.SELECT_REGION
711711
radio_group = 'default'
@@ -827,7 +827,7 @@ class ToolPan(ZoomPanBase):
827827

828828
default_keymap = property(lambda self: mpl.rcParams['keymap.pan'])
829829
description = 'Pan axes with left mouse, zoom with right'
830-
image = 'mpl-data/images/move'
830+
image = '/usr/share/matplotlib/mpl-data/images/move'
831831
cursor = cursors.MOVE
832832
radio_group = 'default'
833833

@@ -891,7 +891,7 @@ def _mouse_move(self, event):
891891
class ToolHelpBase(ToolBase):
892892
description = 'Print tool list, shortcuts and description'
893893
default_keymap = property(lambda self: mpl.rcParams['keymap.help'])
894-
image = 'mpl-data/images/help'
894+
image = '/usr/share/matplotlib/mpl-data/images/help'
895895

896896
@staticmethod
897897
def format_shortcut(key_sequence):

0 commit comments

Comments
 (0)