Skip to content
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

bar3d no longer allows default colors #6989

Closed
matthew-brett opened this issue Aug 27, 2016 · 3 comments
Closed

bar3d no longer allows default colors #6989

matthew-brett opened this issue Aug 27, 2016 · 3 comments
Assignees
Milestone

Comments

@matthew-brett
Copy link
Contributor

For matplotlib 2.0.0b3 on OSX 10.9, homebrew Python 3.5, matplotlib installed via pip.

This file:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.arange(20)
y = np.arange(20)
x2d, y2d = np.meshgrid(x, y)
x2d, y2d = x2d.ravel(), y2d.ravel()
z = x2d + y2d
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z)
plt.show()

generates the following error:

Traceback (most recent call last):
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/matplotlib/colors.py", line 133, in to_rgba
    rgba = _colors_full_map.cache[c, alpha]
KeyError: (None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/matplotlib/colors.py", line 183, in _to_rgba_no_colorcycle
    c = tuple(map(float, c))
TypeError: 'NoneType' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bar_thing.py", line 12, in <module>
    ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z)
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 2459, in bar3d
    sfacecolors = self._shade_colors(facecolors, normals)
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1717, in _shade_colors
    color = mcolors.to_rgba_array(color)
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/matplotlib/colors.py", line 228, in to_rgba_array
    result[i] = to_rgba(cc, alpha)
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/matplotlib/colors.py", line 135, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
  File "/Users/mb312/Library/Python/3.5/lib/python/site-packages/matplotlib/colors.py", line 185, in _to_rgba_no_colorcycle
    raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: None

Adding color='b' to the arguments to ax.bar3d fixes the error.

Matplotlib 1.5.2 on the same platform, via pip, generates no error.

Maybe there's a bug in the default color handling?

@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Aug 27, 2016
@QuLogic
Copy link
Member

QuLogic commented Aug 27, 2016

Bisect points to e524354 (@tacaswell) as the first bad commit:

commit e52435406d0a7a8a8a44a485a753d9ed3a069adc
Author: Thomas A Caswell <tcaswell@gmail.com>
Date:   Thu Apr 28 07:22:21 2016 -0700

    API/ENH: Color cycle handling

    API/ENH: Color cycle handling

:040000 040000 7c0610291ba704cded529513d481fb2bf6f0aedc c181faa9e953b86c548d1f6d8809009498bbcb9b M  examples
:040000 040000 0ebc0950e69c2bbdac4cdb99bd6c4af687d02823 d60a968c83f188c5516eb3447849cdb50bfa54ac M  lib
:100644 100644 f7aa486f09149f0fe499a3a0601b2b95ae9666dc 83ed82e1b930c0ce0512e3c1cdf6c68d2de70b54 M  matplotlibrc.template

@matthew-brett
Copy link
Contributor Author

Kudos for your bisecting skills!

@tacaswell
Copy link
Member

I have a patch

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Aug 27, 2016
If color not specified (default to `None`), get the next color from the
axes color cycle.

closes matplotlib#6989
@tacaswell tacaswell self-assigned this Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants