Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad key "axes.prop_cycle" Error while using an mplstyle in matplotlib (Python)

I am getting the following error when I try to use an external style sheet loaded locally.

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

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()

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'])

I also tried the default from the settings file

axes.prop_cycle : cycler('color', 'bgrcmyk')
like image 488
Craig Avatar asked Oct 19 '22 22:10

Craig


1 Answers

Something must have been messed up with my virtual environment. I thought I was running matplotlib 1.5, but I was actually running 1.4.3. As prop_cycle doesn't exist in that version it turned out that was the source of the error message.

like image 182
Craig Avatar answered Oct 21 '22 15:10

Craig