New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
color_cycle warning with matplotlib 1.5 #68
Comments
I just pushed a version that detects the matplotlib version and uses the appropriate settings. Let me know if it doesn't work for you. |
Hi, I downloaded a fresh copy and I get this error when running the snippet posted by @chadkennedyonline : ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-25-a550bbe40f47> in <module>()
7 sys.path.insert(0,'./code')
8 from book_format import load_style
----> 9 load_style()
/home/dragos/Projects/Kalman-and-Bayesian-Filters-in-Python/code/book_format.pyc in load_style(directory, name)
130 s.pop("axes.color_cycle", None)
131
--> 132 plt.rcParams.update(s)
133 reset_axis ()
134 np.set_printoptions(suppress=True)
ValueError: dictionary update sequence element #0 has length 1; 2 is required When I print (s), I get 1. I'm guessing that rcParams expects a (key,value) pair. Could you please fix this? Not being able to run the first cell messes up the formatting... Thank you! |
@dnstanciu can you tell me your environment - Python version, IPython version, OS, python package if you are using one(anaconda or whatever)? Also the matplotlib version, as my code change behaves differently based on the matplotlib version. I cannot duplicate this here, so I'm hoping this will help me diagnose the problem. Follow up: you said when you print s you get '1'? As in the number 1? When I print s I get {'figure.facecolor': '#ffffff', 'font.size': 14.0, 'figure.subplot.hspace': 0.5, 'examples.directory': '', 'axes.grid': True, 'ytick.major.size': 0, 'figure.subplot.bottom': 0.07, 'axes.facecolor': '#ffffff', 'axes.color_cycle': ['#6d904f', '#013afe', '#202020', '#fc4f30', '#e5ae38', '#A60628', '#30a2da', '#008080', '#7A68A6', '#CF4457', '#188487', '#E24A33'], 'savefig.edgecolor': '#f0f0f0', 'axes.linewidth': 3.0, 'grid.linestyle': '-', 'patch.linewidth': 0.5, 'savefig.facecolor': '#f0f0f0', 'axes.axisbelow': True, 'axes.labelsize': 'large', 'axes.edgecolor': '#f0f0f0', 'xtick.minor.size': 0, 'grid.color': '#cbcbcb', 'patch.edgecolor': '#f0f0f0', 'legend.scatterpoints': 1, 'legend.fancybox': True, 'lines.linewidth': 3, 'axes.titlesize': 'x-large', 'figure.subplot.right': 0.95, 'lines.solid_capstyle': 'butt', 'ytick.minor.size': 0, 'grid.linewidth': 2.0, 'xtick.major.size': 0, 'figure.subplot.left': 0.08} The first lines of the load_style() function read:
I suspect you are not reading the 538.json file for some reason. Are you in the base directory for the book? This code uses relative directories, where |
When I got the error, my setup consisted of: After updating all my PIP packages, I got a new error: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-a550bbe40f47> in <module>()
7 sys.path.insert(0,'./code')
8 from book_format import load_style
----> 9 load_style()
/home/dragos/Projects/testkalmanbook/Kalman-and-Bayesian-Filters-in-Python/code/book_format.py in load_style(directory, name)
127
128 if version[0] > 1 or (version[0] == 1 and version[1] >= 5):
--> 129 s["axes.prop_cycle"] = "cycler('color', ['#6d904f','#013afe', '#202020','#fc4f30','#e5ae38','#A60628','#30a2da','#008080','#7A68A6','#CF4457','#188487','#E24A33'])"
130 s.pop("axes.color_cycle", None)
131
TypeError: 'unicode' object does not support item assignment I realized that the version = [int(s) for s in matplotlib.__version__.split('.')] That explains why I was getting 1 instead of the JSON settings... |
I've accepted the pull request (thanks!) and haven't heard of any more problems, so I'm closing it. Please reopen if you are still having problems. |
When executing
from any page, I get the following warning:
This Python distro is using Matplotlib 1.5.0rc3. I have confirmed that changing the axes.color_cycle line in 538.json to
fixes the warning. But I am unsure how to make the json file conditional based on Matplotlib version, so as to be backwards compatible with older distributions.
The text was updated successfully, but these errors were encountered: