我正试图运行这个例子:
import plotly
plotly.__version__
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot,iplot
# Create random data with numpy
import numpy as np
N = 500
random_x = np.linspace(0, 1, N)
random_y = np.random.randn(N)
# Create a trace
trace = go.Scatter(
x = random_x,
y = random_y
)
data = [trace]
iplot(data, filename='basic-line')
但最后一行iplot ...正在打开iPython并且没有显示图表。 我该如何解决这个问题?
答案 0 :(得分:2)
你错过了这条线
plotly.offline.init_notebook_mode()
<强>代码:强>
import plotly
plotly.__version__
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot,iplot
plotly.offline.init_notebook_mode()
# Create random data with numpy
import numpy as np
N = 500
random_x = np.linspace(0, 1, N)
random_y = np.random.randn(N)
# Create a trace
trace = go.Scatter(
x = random_x,
y = random_y
)
data = [trace]
iplot(data, filename='basic-line')