我剛將matplotlib升級到matplotlib2.0。據我什麼也看不見,應該使用的基本改變,但我現在有這個奇怪的BU與RGB編碼:matplotlib rgb顏色升級後無法正常工作matplotlib
ValueError異常:無效的RGBA的說法:從內核
myDF_DoMS.mean().plot(color =(0.2,0.2,0.7),xticks=np.arange(1,31,1))
plt.plot([1,32],[zeMeanS,zeMeanS],color=(0.2,0.7,0.9))
plt.xlabel('xlabel')
plt.ylabel('Some Score')
plt.title(Study+"\n A name")
plt.show()
投訴0.2
(完整的錯誤堆棧下面)
突然0.2不是浮動了! 如果我把「B」最糟糕的工作原理 而在2號線的其他「RGB」名單上的第2個工作正常(顏色=(0.2,0.7,0.9))...
我有點丟失。
設置: jupyter筆記本中的單元格副本,用於完美地工作。 Python 2.7在anaconda環境中。 Windows 10作爲操作系統。
這裏是輸出:
ValueError Traceback (most recent call
last) C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\IPython\core\formatters.pyc
in __call__(self, obj)
305 pass
306 else:
--> 307 return printer(obj)
308 # Finally look for special method names
309 method = get_real_method(obj, self.print_method)
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\IPython\core\pylabtools.pyc
in <lambda>(fig)
238
239 if 'png' in formats:
--> 240 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
241 if 'retina' in formats or 'png2x' in formats:
242 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\IPython\core\pylabtools.pyc
in print_figure(fig, fmt, bbox_inches, **kwargs)
122
123 bytes_io = BytesIO()
--> 124 fig.canvas.print_figure(bytes_io, **kw)
125 data = bytes_io.getvalue()
126 if fmt == 'svg':
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\backend_bases.pyc
in print_figure(self, filename, dpi, facecolor, edgecolor,
orientation, format, **kwargs) 2198
orientation=orientation, 2199 dryrun=True,
-> 2200 **kwargs) 2201 renderer = self.figure._cachedRenderer 2202 bbox_inches = self.figure.get_tightbbox(renderer)
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\backends\backend_agg.pyc
in print_png(self, filename_or_obj, *args, **kwargs)
543
544 def print_png(self, filename_or_obj, *args, **kwargs):
--> 545 FigureCanvasAgg.draw(self)
546 renderer = self.get_renderer()
547 original_dpi = renderer.dpi
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\backends\backend_agg.pyc
in draw(self)
462
463 try:
--> 464 self.figure.draw(self.renderer)
465 finally:
466 RendererAgg.lock.release()
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
61 def draw_wrapper(artist, renderer, *args, **kwargs):
62 before(artist, renderer)
---> 63 draw(artist, renderer, *args, **kwargs)
64 after(artist, renderer)
65
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\figure.pyc
in draw(self, renderer) 1142 1143
mimage._draw_list_compositing_images(
-> 1144 renderer, self, dsu, self.suppressComposite) 1145 1146 renderer.close_group('figure')
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\image.pyc
in _draw_list_compositing_images(renderer, parent, dsu,
suppress_composite)
137 if not_composite or not has_images:
138 for zorder, a in dsu:
--> 139 a.draw(renderer)
140 else:
141 # Composite any adjacent images together
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
61 def draw_wrapper(artist, renderer, *args, **kwargs):
62 before(artist, renderer)
---> 63 draw(artist, renderer, *args, **kwargs)
64 after(artist, renderer)
65
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\axes\_base.pyc
in draw(self, renderer, inframe) 2424
renderer.stop_rasterizing() 2425
-> 2426 mimage._draw_list_compositing_images(renderer, self, dsu) 2427 2428 renderer.close_group('axes')
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\image.pyc
in _draw_list_compositing_images(renderer, parent, dsu,
suppress_composite)
137 if not_composite or not has_images:
138 for zorder, a in dsu:
--> 139 a.draw(renderer)
140 else:
141 # Composite any adjacent images together
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
61 def draw_wrapper(artist, renderer, *args, **kwargs):
62 before(artist, renderer)
---> 63 draw(artist, renderer, *args, **kwargs)
64 after(artist, renderer)
65
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\lines.pyc
in draw(self, renderer)
801 self._set_gc_clip(gc)
802
--> 803 ln_color_rgba = self._get_rgba_ln_color()
804 gc.set_foreground(ln_color_rgba, isRGBA=True)
805 gc.set_alpha(ln_color_rgba[3])
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\lines.pyc
in _get_rgba_ln_color(self, alt) 1342 1343 def
_get_rgba_ln_color(self, alt=False):
-> 1344 return mcolors.to_rgba(self._color, self._alpha) 1345 1346 # some aliases....
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\colors.pyc
in to_rgba(c, alpha)
141 rgba = _colors_full_map.cache[c, alpha]
142 except (KeyError, TypeError): # Not in cache, or unhashable.
--> 143 rgba = _to_rgba_no_colorcycle(c, alpha)
144 try:
145 _colors_full_map.cache[c, alpha] = rgba
C:\Program
Files\Anaconda2\envs\moonshade\lib\site-packages\matplotlib\colors.pyc
in _to_rgba_no_colorcycle(c, alpha)
192 # float)` and `np.array(...).astype(float)` all convert "0.5" to 0.5.
193 # Test dimensionality to reject single floats.
--> 194 raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
195 # Return a tuple to prevent the cached value from being modified.
196 c = tuple(c.astype(float))
ValueError: Invalid RGBA argument: 0.2
<matplotlib.figure.Figure at 0x14e54ac8>
只需添加,第一個調用的對象就是一個熊貓數據框。這個問題可以很容易地解決,只需使用任何其他顏色代碼,如xkcd或字母作品,它只是令人困惑(對我來說)令人困惑。 –
如果您忘記添加某些內容到您的問題中,只需編輯它,而不是評論。請注意,當你提供問題時,幫助你總是更容易。由於我們沒有你的數據框,我們只能猜測。偶然繪製的數據框是否有3列? – ImportanceOfBeingErnest