如何在 IPython 笔记本内部的 Matplotlib 中向 xy 线图添加图例?我目前的尝试:
x = np.linspace(0, 3*np.pi, 500)
a = plt.plot(x, np.sin(x**2))
b = plt.plot(x, np.sin(x**0.5))
plt.legend([a,b], ['square', 'square root'])
这样做,我收到以下错误:
/Users/mc/.virtualenvs/kaggle/lib/python2.7/site-packages/matplotlib/legend.py:613: UserWarning: Legend does not support [] 使用代理艺术家。
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
(str(orig_handle),)) /Users/mc/.virtualenvs/kaggle/lib/python2.7/site-packages/matplotlib/legend.py:613: UserWarning: Legend does not support [] 使用代理艺术家。
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
(str(orig_handle),))
如果我不这样做,则此命令有效plt.scatter
,plt.plot
但我想要一个折线图而不是 x,y 点。