-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Milestone
Description
Bug report
Bug summary
Histogram function color keyword argument is broken for multiple empty datasets.
Code for reproduction
plt.hist([[], []], color=["k", "r"])Actual outcome
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-ea1bc187199f> in <module>()
----> 1 plt.hist([[], []], color=["k", "r"])
~/.miniconda/envs/leanheat/lib/python3.5/site-packages/matplotlib/pyplot.py in hist(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, normed, hold, data, **kwargs)
3130 histtype=histtype, align=align, orientation=orientation,
3131 rwidth=rwidth, log=log, color=color, label=label,
-> 3132 stacked=stacked, normed=normed, data=data, **kwargs)
3133 finally:
3134 ax._hold = washold
~/.miniconda/envs/leanheat/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1853 "the Matplotlib list!)" % (label_namer, func.__name__),
1854 RuntimeWarning, stacklevel=2)
-> 1855 return func(ax, *args, **kwargs)
1856
1857 inner.__doc__ = _add_data_doc(inner.__doc__,
~/.miniconda/envs/leanheat/lib/python3.5/site-packages/matplotlib/axes/_axes.py in hist(***failed resolving arguments***)
6502 color = mcolors.to_rgba_array(color)
6503 if len(color) != nx:
-> 6504 raise ValueError("color kwarg must have one color per dataset")
6505
6506 # If bins are not specified either explicitly or via range,
ValueError: color kwarg must have one color per dataset
Expected outcome
Should work as plt.hist([[], []]) works.
Matplotlib version
- Operating system: Linux (NixOS)
- Matplotlib version: 2.2.2
- Matplotlib backend (
print(matplotlib.get_backend())): - Python version: 3.5
- Jupyter version (if applicable):
- Other libraries:
Installed matplotlib from default conda channel.