根据问题,我试图在Google colab中使用plotly绘制一个简单的图形,但是却得到一个空白图形。我遵循了this和this,但是没有用。
这是我的代码:
Cell1
import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode, plot
import numpy as np
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-latest.min.js?noext',
},
});
</script>
'''))
Cell2
x = np.arange(10)
y = np.random.random(10) * 3 + x
trace = go.Scatter(x=x, y=y)
configure_plotly_browser_state()
init_notebook_mode(connected=False)
iplot([trace])