[英]Plotly in Python: How to add legend when using matplotlib?
In plotly, you can convert a matplotlib figure into plot.ly: 在plotly中,您可以将matplotlib图转换为plot.ly:
x=[1,2,3] y=[4,5,6] plt.plot(x,y,label='test') fig=plt.gcf() x = [1,2,3] y = [4,5,6] plt.plot(x,y,label ='test')fig = plt.gcf()
However, if I add legend, 但是,如果我添加图例,
x=[1,2,3]
y=[4,5,6]
plt.plot(x,y,label='test')
fig=plt.gcf()
plt.legend()
It will return error RuntimeError: Cannot get window extent w/o renderer
它将返回错误RuntimeError: Cannot get window extent w/o renderer
I want to know what is the problem? 我想知道这是什么问题? Does plot.ly support legend made with matplotlib? plot.ly是否支持使用matplotlib制作的图例?
将showlegend=True
添加到plt.plot(x,y,label='test')
可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.