-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matplotlib.style.available not updated upon adding/deleting .mplstyle files #3601
Comments
attn @tonysyu |
Thanks for pinging me @tacaswell. @RubenGeert: Does the following show a different number of styles for the last print statement? from __future__ import print_function
import os
from contextlib import contextmanager
import matplotlib.pyplot as plt
from matplotlib.style.core import USER_LIBRARY_PATHS
@contextmanager
def temp_style_file(name):
""" A context manager for creating an empty style file in the expected path.
"""
filename = os.path.join(USER_LIBRARY_PATHS[0], name)
with open(filename, 'w'):
pass
yield
os.remove(filename)
print('# styles available:', len(plt.style.available))
with temp_style_file('dummy.mplstyle'):
print('# before reload:', len(plt.style.available))
plt.style.reload_library()
print('# after reload:', len(plt.style.available)) Aside: I thought I added |
Hi Tony! On running the last commands, I got:
Is Should I replace a line in Sorry if those my questions are somewhat basic, I'm not exactly a Python expert. |
The test script is complaining that you haven't created a stylelib directory (this is where matplotlib is looking for style files). Could you replace the @contextmanager
def temp_style_file(name):
""" A context manager for creating an empty style file in the expected path.
"""
stylelib_path = USER_LIBRARY_PATHS[0]
if not os.path.exists(stylelib_path):
os.makedirs(stylelib_path)
filename = os.path.join(stylelib_path, name)
with open(filename, 'w'):
pass
yield
os.remove(filename) and see if that prints out the expected values? The last print statement should list one more file than the others. That said, since that directory doesn't already exist, it suggests you weren't creating files in the correct location. Where were you putting your custom style files? Changes to style files should be visible after calling |
@tonysyu : yes, the modification solved the problem. After I first put the new stylesheet into And, indeed, I came a long way by using Thanks again for the assistance! |
I've added a response to stackoverflow just for posterity. This issue should probably be closed. |
I thought there was a user space folder for adding style files? |
Dear all,
I've been having the problem that the available styles only seem to be updated upon rebooting my system. I discussed the issue here: http://stackoverflow.com/questions/26106552/matplotlib-style-library-not-updating-when-mplstyle-files-added-deleted.
Is this normal? What should I do?
The text was updated successfully, but these errors were encountered: