话不多说,上代码
import math
import pyecharts.options as opts
from pyecharts.charts import Line3D
data = []
for t in range(35000):
_t = t/1000
x = (2 + 0.25 * math.cos((75 * _t))) * math.cos(_t)
y = (2 + 0.25 * math.cos((75 * _t))) * math.sin(_t)
z = _t + 2 * math.sin(75 * _t)
data.append([x, y, z])
(
Line3D(opts.InitOpts(width='1280px',height='720px',page_title='The 3D picture'))
.add(
'',
data,
xaxis3d_opts=opts.Axis3DOpts(type_='value'),
yaxis3d_opts=opts.Axis3DOpts(type_='value'),
grid3d_opts=opts.Grid3DOpts(
width=100,
height=100,
depth=100,
rotate_speed=20,
is_rotate=True
)
)
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(
dimension=2,
max_=30,
min_=0,
range_color=[
'#424695',
'#5545b4',
'#85bdd1',
'#cde9e9',
'#f1f3f8',
'#ffffbf',
'#fef090',
'#fdbe72',
'#f47d54',
'#d85027',
'#a62025',
]
)
)
.render('3D picture.html')
)
|