Skip to content

Commit c008667

Browse files
committed
Try to load local version of mplstyle if needed
1 parent 1ad1c5e commit c008667

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stagpy/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,22 @@ def load_mplstyle():
6868
plt = importlib.import_module('matplotlib.pyplot')
6969
if conf.plot.mplstyle:
7070
for style in conf.plot.mplstyle.split():
71+
found = False
7172
if not ISOLATED:
7273
stfile = config.CONFIG_DIR / (style + '.mplstyle')
74+
if stfile.is_file():
75+
found = True
76+
style = str(stfile)
77+
if not found:
78+
# try local version
79+
stfile = pathlib.Path(__file__).parent / (style + '.mplstyle')
7380
if stfile.is_file():
7481
style = str(stfile)
7582
try:
7683
plt.style.use(style)
7784
except OSError:
78-
if not ISOLATED or DEBUG:
79-
print('Cannot import style {}.'.format(style),
80-
file=sys.stderr)
85+
print('Cannot import style {}.'.format(style),
86+
file=sys.stderr)
8187
conf.plot.mplstyle = ''
8288
if conf.plot.xkcd:
8389
plt.xkcd()

0 commit comments

Comments
 (0)