python - 错误 key "axes.prop_cycle"在 matplotlib (Python) 中使用 mplstyle 时出错

标签 python pandas matplotlib

当我尝试使用本地加载的外部样式表时,出现以下错误。

Bad key "axes.prop_cycle" on line 270 in
idt.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

我需要能够轻松地使用代码分发此样式表,因此不能选择保存到样式文件夹。也就是说,我可以毫无问题地从该文件夹中运行样式。如果我将样式从文件夹复制到本地,那么该行将停止工作。

除了颜色循环器之外,样式表的所有其他方面都必须遵守。我尝试过将默认样式表从文件夹中复制出来,但这也不起作用。

这是代码:

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from matplotlib.ticker import FuncFormatter
%matplotlib inline    
rev_by_qtr = pd.read_csv("rev_by_qtr.csv")    
rev_by_qtr = rev_by_qtr.set_index('market_family')
plt.style.use('idt.mplstyle') # This is a local style sheet
ax = rev_by_qtr.T.plot()

这是样式表中的第 270 行

axes.prop_cycle    : cycler('color', ['E24A33', 'AEC7E8', 'FF07FE', 'FFBB78', '2CA02C', '98DF8A', 'D62728', 'FF9896', '9467BD', 'C5B0D5', '8C564B', 'C49C94', 'E377C2', 'F7B6D2', '7F7F7F', 'C7C7C7', 'BCBD22', 'DBDB8D', '17BECF', '9EDAE5'])

我还尝试了设置文件中的默认值

axes.prop_cycle : cycler('color', 'bgrcmyk')

最佳答案

我的虚拟环境肯定出了什么问题。我以为我运行的是 matplotlib 1.5,但实际上运行的是 1.4.3。由于该版本中不存在 prop_cycle,因此事实证明这是错误消息的来源。

关于python - 错误 key "axes.prop_cycle"在 matplotlib (Python) 中使用 mplstyle 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33747933/

相关文章:

python - 如何修复 Pylint "Wrong hanging indentation"和 PEP8 E121?

python - 不根据前 x 值插值绘制数据

Python Matplotlib : Splitting one Large Graph into several Sub-Graphs (Subplot)

python - 填充等高线图顶部的绘图点增加了大量空白

python - 将 REST API 的 JSON 响应作为输入数据传递到 APACHE SOLR 中

python - 使用 Python 在 Twitter 1.1 中发出仅应用程序请求

python - pip3 抛出 undefined symbol : XML_SetHashSalt

pandas - 根据 Pandas 中的前三行转换数据框

Python 创建数字序列并按组附加

python - 线性回归在 Python 中失败,因变量中的值很大