-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Description
To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.
Bug report
I tried to plot a "barplot" referring to the demo scripts in http://matplotlib.org/examples/style_sheets/style_sheets_reference.html.
But the console showed :
ValueError: to_rgba: Invalid rgba arg "2"
to_rgb: Invalid rgb arg "2"
gray (string) must be in range 0-1
on this line: ax.bar(np.arange(6)+0.25,test_cas,0.25,color='C2')
Code for reproduction
http://matplotlib.org/mpl_examples/style_sheets/style_sheets_reference.py
Actual outcome
- The output produced by the above code, which may be a screenshot, console output, etc.
E:\Programing\Python>ipython style_sheets_reference.py
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
E:\Programing\Python\style_sheets_reference.py in <module>()
142 for style_label in style_list:
143 with plt.style.context(style_label):
--> 144 fig = plot_figure(style_label=style_label)
145
146 plt.show()
E:\Programing\Python\style_sheets_reference.py in plot_figure(style_label)
118 plot_scatter(axes[0], prng)
119 plot_image_and_patch(axes[1], prng)
--> 120 plot_bar_graphs(axes[2], prng)
121 plot_colored_circles(axes[3], prng)
122 plot_colored_sinusoidal_lines(axes[4])
E:\Programing\Python\style_sheets_reference.py in plot_bar_graphs(ax, prng, min_value, max_value, nb_samples)
44 width = 0.25
45 ax.bar(x, ya, width)
---> 46 ax.bar(x + width, yb, width, color='C2')
47 ax.set_xticks(x + width)
48 ax.set_xticklabels(['a', 'b', 'c', 'd', 'e'])
C:\Users\yanya\Miniconda2\lib\site-packages\matplotlib\__init__.pyc in inner(ax, *args, **kwargs)
1816 warnings.warn(msg % (label_namer, func.__name__),
1817 RuntimeWarning, stacklevel=2)
-> 1818 return func(ax, *args, **kwargs)
1819 pre_doc = inner.__doc__
1820 if pre_doc is None:
C:\Users\yanya\Miniconda2\lib\site-packages\matplotlib\axes\_axes.pyc in bar(self, left, height, width, bottom, **kwargs)
2015 color = [None] * nbars
2016 else:
-> 2017 color = list(mcolors.colorConverter.to_rgba_array(color))
2018 if len(color) == 0: # until to_rgba_array is changed
2019 color = [[0, 0, 0, 0]]
C:\Users\yanya\Miniconda2\lib\site-packages\matplotlib\colors.pyc in to_rgba_array(self, c, alpha)
420 result = np.zeros((nc, 4), dtype=np.float)
421 for i, cc in enumerate(c):
--> 422 result[i] = self.to_rgba(cc, alpha)
423 return result
424
C:\Users\yanya\Miniconda2\lib\site-packages\matplotlib\colors.pyc in to_rgba(self, arg, alpha)
374 except (TypeError, ValueError) as exc:
375 raise ValueError(
--> 376 'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
377
378 def to_rgba_array(self, c, alpha=None):
ValueError: to_rgba: Invalid rgba arg "2"
to_rgb: Invalid rgb arg "2"
gray (string) must be in range 0-1
Matplotlib version
install by anaconda
conda 4.3.11
Python 2.7.12
IPython 5.1.0
In [3]: matplotlib.__version__
Out[3]: '1.5.3'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels