在 matplotlib (Python) 中使用 mplstyle 时出现错误键“axes.prop_cycle”错误

Cra*_*aig 5 python matplotlib pandas

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

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
Run Code Online (Sandbox Code Playgroud)

I need to be able to distribute this style sheet with the code easily, so saving to the styles folder isn't an option. That said, I can run styles out of that folder no problem. If I copy the style from the folder to local then that line stops working.

All other aspects of the style sheet are obeyed with exception of the color cycler. I've tried simply copying the default style sheets out of the folder but that doesn't work either.

This is the code:

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()
Run Code Online (Sandbox Code Playgroud)

Here is line 270 from the style sheet

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'])
Run Code Online (Sandbox Code Playgroud)

I also tried the default from the settings file

axes.prop_cycle : cycler('color', 'bgrcmyk')
Run Code Online (Sandbox Code Playgroud)

Cra*_*aig 3

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