示例#1
0
def line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    c = (Line3D().add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100,
                                    height=100,
                                    depth=100,
                                    rotate_speed=150,
                                    is_rotate=True),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=30,
                                          min_=0,
                                          range_color=Faker.visual_color),
        title_opts=opts.TitleOpts(title="Line3D-旋转的弹簧"),
    ))
    return c
示例#2
0
def test_line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    c = (Line3D().add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    ).set_global_opts(visualmap_opts=opts.VisualMapOpts(
        max_=30, min_=0, range_color=Faker.visual_color)))
    eq_(c.theme, "white")
    eq_(c.renderer, "canvas")
    c.render()
示例#3
0
def line3d():
    week_en = "Saturday Friday Thursday Wednesday Tuesday Monday Sunday".split(
    )
    clock = ("12a 1a 2a 3a 4a 5a 6a 7a 8a 9a 10a 11a 12p "
             "1p 2p 3p 4p 5p 6p 7p 8p 9p 10p 11p".split())
    _data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        _data.append([x, y, z])
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    line3d = Line3D()
    line3d.set_global_opts(visualmap_opts=opts.VisualMapOpts(
        dimension=2,
        max_=30,
        min_=0,
        range_color=[
            "#313695",
            "#4575b4",
            "#74add1",
            "#abd9e9",
            "#e0f3f8",
            "#ffffbf",
            "#fee090",
            "#fdae61",
            "#f46d43",
            "#d73027",
            "#a50026",
        ],
    ))
    line3d.add(
        "",
        _data,
        xaxis3d_opts=opts.Axis3DOpts(data=clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(data=week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    )
    return line3d
示例#4
0
def line3d_base():
    data = []
    for t in range(0, 25000):
        _t = t / 1000
        x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
        y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
        z = _t + 2.0 * math.sin(75 * _t)
        data.append([x, y, z])
    line3d = Line3D()
    line3d.add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, depth=100),
    )
    line3d.set_global_opts(
        title_opts=opts.TitleOpts(title="Line3D-基本示例"),
        visualmap_opts=opts.VisualMapOpts(max_=30)
    )
    line3d.render("./line3d_base.html")
示例#5
0
def line_3d_fun():
    # 三维数据,定义 x、y 长度,z 数值随机
    data = [(i, j, random.randint(1, 20)) for i in range(7) for j in range(10)]
    print(len(data), data)
    Line3D().add(
        # 添加 x、y、z 轴数据,并设置属性
        series_name="",
        data=data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.choose(), type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.choose(), type_="value"),
        zaxis3d_opts=opts.Axis3DOpts(Faker.values(), type_="value"),
        # 添加旋转效果
        grid3d_opts=opts.Grid3DOpts(width=100,
                                    depth=100,
                                    rotate_speed=150,
                                    is_rotate=True),
    ).set_global_opts(
        # 设置图表属性
        # 视觉配置
        visualmap_opts=opts.VisualMapOpts(max_=20),
        title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")).render(
            # 设置输出路径
            path="D:/temp/pyecharts_line3d.html")
    _t = t / 1000
    x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
    y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
    z = _t + 2.0 * math.sin(75 * _t)
    data.append([x, y, z])

(Line3D().add(
    "",
    data,
    xaxis3d_opts=opts.Axis3DOpts(data=clock, type_="value"),
    yaxis3d_opts=opts.Axis3DOpts(data=week_en, type_="value"),
    grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
).set_global_opts(visualmap_opts=opts.VisualMapOpts(
    dimension=2,
    max_=30,
    min_=0,
    range_color=[
        "#313695",
        "#4575b4",
        "#74add1",
        "#abd9e9",
        "#e0f3f8",
        "#ffffbf",
        "#fee090",
        "#fdae61",
        "#f46d43",
        "#d73027",
        "#a50026",
    ],
)).render("line3d_rectangular_projection.html"))
    x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
    y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
    z = _t + 2.0 * math.sin(75 * _t)
    data.append([x, y, z])

# In[131]:

c = (
    Line3D().add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100,
                                    depth=100,
                                    rotate_speed=150,
                                    is_rotate=True),
    ).set_global_opts(
        visualmap_opts=opts.VisualMapOpts(max_=30,
                                          min_=0,
                                          range_color=Faker.visual_color),
        title_opts=opts.TitleOpts(title="Line3D-旋转的弹簧"),
    )
    #.render("line3d_autorotate.html")
)
c.render_notebook()

# In[137]:

# vis
import pyecharts.options as opts