情节未在 Colab 中显示

问题描述 投票:0回答:1

我正在使用colab并尝试使用plotly,但它没有显示任何内容,没有错误,但也没有绘图,它只是扩展输出,因为它显示它,但什么也没有。我虽然可能是主题扩展,但我卸载了它,什么也没有。

import cufflinks as cf
import plotly.express as px
import plotly.graph_objects as go

from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
cf.go_offline()

df_stocks = px.data.stocks()
px.line(df_stocks, x='date', y='GOOG', labels={'x':'Date', 'y':'Price'})
plotly
1个回答
0
投票

从上面的代码中,您没有明确确保您正在使用的

renderer
。渲染器让 Plotly 知道在哪个环境中显示绘图。您必须将其作为字符串传递,或者作为
colab or notebook


figure = px.line(df_stocks, x='date', y='GOOG', labels={'x':'Date', 'y':'Price'})
figure.show(renderer='colab') # or use this instead; figure.show(renderer='notebook')


© www.soinside.com 2019 - 2024. All rights reserved.