8000 bar3d no longer allows default colors · Issue #6989 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
bar3d no longer allows default colors #6989
Closed
@matthew-brett

Description

@matthew-brett

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0