AttributeError: 'module' object has no attribute 'to_rgba'

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属性。
谢谢大佬

https://access.redhat.com/solutions/1543773

U can try this, It may works.

 sudo pip install matplotlib==2.2.0

可能是matplotlib版本问题。
我碰到的是matplotlib 3.2.1的实时,ColorbarBase.to_rgba()函数是被去除了。
只要把matplib回退到 3.0.2版本就可以正常工作了。