joe*_*ks3 1 python flask plotly
我有一些旧代码,以类似的方式在同一张图上绘制很多线
import plotly.plotly as py
import plotly.graph_objs as go
data = [regtimes, avg5times]
py.iplot(data, filename='basic-line')
Run Code Online (Sandbox Code Playgroud)
这将在同一个图上绘制两条线。我尝试再次使用它,它说plotly.plotly已被弃用。现在我有类似的东西
individualtimes = go.Scatter(
y = times,
x = x1,
)
test = go.Scatter(
y2=[1, 1, 5],
x2=x1
)
data = [individualtimes,test]
fig = go.Figure(data=data)
fig.show()
Run Code Online (Sandbox Code Playgroud)
有没有办法使用Fig.show来绘制这样的多条线?谢谢!
我已经找到答案了!已更改为使用 add_trace 然后显示该图。情节用途
import plotly.graph_objects as go
# Create random data with numpy
import numpy as np
np.random.seed(1)
N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N) + 5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N) - 5
# Create traces
fig = go.Figure()
fig.add_trace(go.Scatter(x=random_x, y=random_y0,
mode='lines',
name='lines'))
fig.add_trace(go.Scatter(x=random_x, y=random_y1,
mode='lines+markers',
name='lines+markers'))
fig.add_trace(go.Scatter(x=random_x, y=random_y2,
mode='markers', name='markers'))
fig.show()
Run Code Online (Sandbox Code Playgroud)
其余部分可以在这里找到。