我只是在尝试绘图/破折号,当我写下面的代码时,什么都没有显示..这只是一个空白框。我已经尝试安装nodejs(我正在使用anaconda),以便我可以尝试安装一些扩展名'jupyter labextension install @ jupyterlab / plotly-extension',但这由于某些原因无法工作,甚至无法安装nodejs。
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.offline as pyo
import plotly.graph_objs as go
# Set notebook mode to work in offline
pyo.init_notebook_mode()
#init_notebook_mode(connected=True)
# Create traces
trace0 = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = go.Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
# Fill out data with our traces
data = [trace0, trace1]
layout=go.Layout(barmode='stack')
fig=go.Figure(data=data, layout=layout)
# Plot it and save as basic-line.html
pyo.iplot(fig, filename = 'basic-line')
我还能做些什么来帮助查看我的图表?
答案 0 :(得分:0)
我想了解更多有关plolty,Jupyterlab等版本的信息,但是iplot()
很有可能是这里的问题。尝试另一个基本示例,例如:
代码:
import plotly.graph_objects as go
animals=['giraffes', 'orangutans', 'monkeys']
fig = go.Figure(data=[
go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23]),
go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
])
# Change the bar mode
fig.update_layout(barmode='stack')
fig.show()
情节:
让我知道如何为您解决问题。
答案 1 :(得分:0)
您可以尝试根据Google Colab的说明进行Plotly降级
def configure_plotly_browser_state():
import IPython
display(IPython.core.display.HTML('''
<script src="/static/components/requirejs/require.js"></script>
<script>
requirejs.config({
paths: {
base: '/static/base',
plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
},
});
</script>
'''))
调用此函数configure_plotly_browser_state()
答案 2 :(得分:0)
当您运行代码并弹出浏览器时,点击地址栏中的 并按 Enter。