Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 添加/删除.mplstyle文件时matplotlib样式库未更新_Python 2.7_Matplotlib_Python Import - Fatal编程技术网

Python 2.7 添加/删除.mplstyle文件时matplotlib样式库未更新

Python 2.7 添加/删除.mplstyle文件时matplotlib样式库未更新,python-2.7,matplotlib,python-import,Python 2.7,Matplotlib,Python Import,我试图创建自己的matplotlib样式表,但Python没有检测到它们。更糟糕的是:当我移动五个默认样式表(ggplot.mplstyle)中的一个时,Python一直报告它是可用的 我试图重新加载整个模块,但没有成功: import matplotlib reload(matplotlib) from matplotlib import style as style plt = matplotlib.pyplot print plt.style.available 只是不断地回来 [u'd

我试图创建自己的matplotlib样式表,但Python没有检测到它们。更糟糕的是:当我移动五个默认样式表(ggplot.mplstyle)中的一个时,Python一直报告它是可用的

我试图重新加载整个模块,但没有成功:

import matplotlib
reload(matplotlib)
from matplotlib import style as style
plt = matplotlib.pyplot
print plt.style.available
只是不断地回来

[u'dark_background', u'bmh', u'grayscale', u'ggplot', u'fivethirtyeight']
如何强制“刷新”这些样式


另外,我不是Python专家。

为了防止其他人无意中发现这篇文章,在这里报告并解决了这个问题:

基本上,样式库在matplotlib配置目录的子目录中查找文件。在linux/osx系统上,这类似于
~/.matplotlib/stylelib/.mplstyle


此外,正如@tcaswell在注释中所建议的那样,加载是在导入时完成的,因此导入后添加或编辑的样式文件如果不调用
plt.style.reload\u library()

看起来像
plt.style.reload\u library()
将执行以下操作:trick@tcaswell谢谢你的建议,但似乎没什么不同。顺便说一句,也不会抛出任何错误消息。那么你能将其报告为错误吗?实际上,如果你执行
matplotlib.style.reload_library()
然后执行
matplotlib.style.available
?@tcaswell:仍然没有运气。我会按照你的建议把它报告为bug。