import plotly.offline as of
import plotly.graph_objs as go
of.offline.init_notebook_mode(connected=True)
trace0 = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17],
mode='markers'
)
trace1 = go.Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = go.Data([trace0, trace1])
of.plot(data)

import numpy as np
import plotly.offline as of
import plotly.graph_objs as go
import plotly.plotly as py
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
trace0 = go.Scatter(
x = random_x,
y = random_y0,
mode = 'markers',
name = 'markers'
)
trace1 = go.Scatter(
x = random_x,
y = random_y1,
mode = 'lines+markers',
name = 'lines+markers'
)
trace2 = go.Scatter(
x = random_x,
y = random_y2,
mode = 'lines',
name = 'lines'
)
data = [trace0, trace1, trace2]
of.plot(data)

import numpy as np
import plotly.offline as of
import plotly.graph_objs as go
import plotly.plotly as py
day1=[4130,2900,1843,1211,1052,1094,2080,7493,10453,13406,12656,11888,11781,14345,14708,13111,12796,13282,12431,11818,10808,10464,8610,5108,0]
day2=[5125,3479,2268,1541,1274,1047,1659,5237,9199,11019,11670,12677,13066,15714,15597,14613,14271,14903,14418,13441,13112,11473,9013,5264,0]
hours=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
trace0 = go.Scatter(
x = hours,
dx=1,
y = day1,
text=day1,
mode='lines+markers',
name = '工作日'
)
trace1 = go.Scatter(
x = hours,
dx=1,
y = day2,
text=day2,
mode = 'lines+markers',
name = '节假日'
)
data = [trace0, trace1]
layout = go.Layout(title='随时间变化的一天中的订单需求量',
titlefont={
'size':20
},
xaxis={
'title':'小时(hours)',
'showgrid' : False,
'titlefont':{
'size':15
}
},yaxis={
'title':'乘客打车需求量',
'titlefont':{
'size':15
}
})
fig = go.Figure(data=data, layout=layout)
of.plot(fig)

import numpy as np
import plotly.offline as of
import plotly.graph_objs as go
import plotly.plotly as py
day1=[4130,2900,1843,1211,1052,1094,2080,7493,10453,13406,12656,11888,11781,14345,14708,13111,12796,13282,12431,11818,10808,10464,8610,5108,0]
day2=[5125,3479,2268,1541,1274,1047,1659,5237,9199,11019,11670,12677,13066,15714,15597,14613,14271,14903,14418,13441,13112,11473,9013,5264,0]
hours=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
trace0 = go.Scatter(
x = hours,
dx=1,
y = day1,
text=day1,
fill="tonexty",
mode='lines+markers',
name = '工作日'
)
trace1 = go.Scatter(
x = hours,
dx=1,
y = day2,
text=day2,
fill="tonexty",
mode = 'lines+markers',
name = '节假日'
)
data = [trace0, trace1]
layout = go.Layout(title='随时间变化的一天中的订单需求量',
titlefont={
'size':20
},
xaxis={
'title':'小时(hours)',
'showgrid' : False,
'zeroline' : True,
'titlefont':{
'size':15
}
},yaxis={
'title':'乘客打车需求量',
'zeroline' : True,
'titlefont':{
'size':15
}
})
fig = go.Figure(data=data, layout=layout)
of.plot(fig)
