Closed
Description
Many (most?) matplotlib functions accept a numeric object for the label
kwarg. For example, this works fine:
x = np.random.randn(50)
plt.plot(x, label=0)
plt.legend()
However, the same is not true for plt.hist
:
x = np.random.randn(50)
plt.hist(x, label=0)
plt.legend()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-27407c59c8b6> in <module>()
1 x = np.random.randn(50)
----> 2 plt.hist(x, label=0)
3 plt.legend()
/Users/mwaskom/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, **kwargs)
2894 histtype=histtype, align=align, orientation=orientation,
2895 rwidth=rwidth, log=log, color=color, label=label,
-> 2896 stacked=stacked, **kwargs)
2897 draw_if_interactive()
2898 finally:
/Users/mwaskom/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
5858 else:
5859 raise ValueError(
-> 5860 'invalid label: must be string or sequence of strings')
5861
5862 if len(labels) < nx:
ValueError: invalid label: must be string or sequence of strings
Is there a reason for this constraint on histogram labels?
Metadata
Metadata
Assignees
Labels
No labels