I met a strange problem when i using matplotlib with python 2.7, ubuntu 16.04 and jupyter web.
The code is very simple, like:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x,y)
plt.show()
[]
AttributeError Traceback (most recent call last)
/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in show(close, block)
37 display(
38 figure_manager.canvas.figure,
---> 39 metadata=_fetch_figure_metadata(figure_manager.canvas.figure)
40 )
41 finally:
/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in _fetch_figure_metadata(fig)
172 """Get some metadata to help with displaying a figure."""
173 # determine if a background is needed for legibility
--> 174 if _is_transparent(fig.get_facecolor()):
175 # the background is transparent
176 ticksLight = _is_light([label.get_color()
/home/******/.local/lib/python2.7/site-packages/ipykernel/pylab/backend_inline.pyc in _is_transparent(color)
193 def _is_transparent(color):
194 """Determine transparency from alpha."""
--> 195 rgba = colors.to_rgba(color)
196 return rgba[3] < .5
AttributeError: 'module' object has no attribute 'to_rgba'
国外的一个朋友问我的,我也不知道为什么,matplotlib在终端用的好好地,在jupyter notebook中就报错了.......
很奇怪的一个错误, 哪位大佬帮解决一下。 错误指向colors没有to_rgba属性。
谢谢大佬