1.面积图
import plotly as py
import plotly.graph_objs as go
import numpy as np
pyplt = py.offline.plot
random_state1 = np.random.RandomState(0)
random_state2 = np.random.RandomState(2)
num1 = random_state1.rand(100) / 10
num2 = random_state2.rand(100) / 10
print('num1:',num1)
print('num2:',num2)
og1 = 10000
og2 = 10000
fund1 = []
fund2 = []
for i in list(range(100)):
og1 = og1 * num1[i] + og1
og2 = og2 * num2[i] + og2
fund1.append(og1)
fund2.append(og2)
trace1 = go.Scatter(
y = fund1,
fill = 'tonexty',
mode = 'none',
name = "基金一号"
)
trace2 = go.Scatter(
y = fund2,
fill = 'tonexty',
mode = 'none',
name = "基金二号"
)
data = [trace1, trace2]
layout = dict(title = '基金波动曲线',
xaxis = dict(title = '交易天数'),
yaxis = dict(title = '净值'),
)
fig = dict(data = data, layout = layout)
pyplt(fig, filename = 'D:\基金波动曲线.html')
