我正在生成从第1天开始到第1天结束的随机步行时间系列,
我想在我的x_axis上表示日期,该系列从输入输入建立的起始日期开始,到结束日期“ l”为止
此代码生成时间序列:
import plotly.graph_objects as go
import numpy as np
l = 360 # Number of days to Study
time_step = 1
# initial_y = int(input('Enter initial value: '))
x_steps = np.random.choice([0, 0], size=l) + time_step # l steps
y_steps = np.random.choice([-1, 1], size=l) + 0.2 * np.random.randn(l) # l steps
x_position = np.cumsum(x_steps) # integrate the position by summing steps values
y_position = np.cumsum(y_steps) # integrate the position by summing steps values
fig = go.Figure(data=go.Scatter(
x=x_position,
xcalendar='gregorian',
# range_x=['2015-12-01', '2016-01-15'],
y=y_position + 1500,
mode='lines+markers',
name='Random Walk',
marker=dict(
color=np.arange(l),
size=8,
colorscale='Greens',
showscale=False
)
))
fig.show()
您可以在示例中添加以下内容: