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

2024/9/27 17:26:17

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

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.

https://en.xdnf.cn/q/71432.html

Related Q&A

Dollar notation in script languages - why? [closed]

Closed. This question is off-topic. It is not currently accepting answers.Want to improve this question? Update the question so its on-topic for Stack Overflow.Closed 12 years ago.Improve this questio…

Failure to build wheel / Error: INCLUDE Environment Variable is empty

I am using Python 2.7.11 and am trying to pip install modules however a few of them are failing. The message I get is "Failure to build wheel for X" and "Error: INCLUDE Environment Varia…

Calculating the position of QR Code alignment patterns

I need to know how to calculate the positions of the QR Code alignment patterns as defined in the table of ISO/IEC 18004:2000 Annex E.I dont understand how its calculated. If you take the Version 16, f…

Lowlevel introspection in python3?

Is there some introspection method allowing to reliably obtain the underlying data structure of an object instance, that is unaffected by any customizations? In Python 3 an objects low-level implement…

Efficiently find indices of nearest points on non-rectangular 2D grid

I have an irregular (non-rectangular) lon/lat grid and a bunch of points in lon/lat coordinates, which should correspond to points on the grid (though they might be slightly off for numerical reasons).…

How to code a sequence to sequence RNN in keras?

I am trying to write a sequence to sequence RNN in keras. I coded this program using what I understood from the web. I first tokenized the text then converted the text into sequence and padded to form …

Error when installing psycopg2 on Windows 10

Collecting psycopg2Using cached psycopg2-2.6.1.tar.gzComplete output from command python setup.py egg_info:running egg_infocreating pip-egg-info\psycopg2.egg-infowriting pip-egg-info\psycopg2.egg-info\…

Speeding up Pandas apply function

For a relatively big Pandas DataFrame (a few 100k rows), Id like to create a series that is a result of an apply function. The problem is that the function is not very fast and I was hoping that it can…

Numpy repeat for 2d array

Given two arrays, say arr = array([10, 24, 24, 24, 1, 21, 1, 21, 0, 0], dtype=int32) rep = array([3, 2, 2, 0, 0, 0, 0, 0, 0, 0], dtype=int32)np.repeat(arr, rep) returns array([10, 10, 10, 24, 24, 2…

Python Linux route table lookup

I posted Python find first network hop about trying to find the first hop and the more I thought about it, the easier it seemed like it would be a process the routing table in python. Im not a program…