plotly三维数据散点,Python

import numpy as np
import plotly.graph_objs as go


def f(x, y):
    z = np.power(x, 2) + np.power(y, 2)
    return z


if __name__ == '__main__':
    # num个从0到10的线性数据点。
    x = y = np.linspace(start=0, stop=10, num=1000)
    # z=x*x + y*y
    z = f(x, y)

    data = [
        go.Scatter3d(
            x=x,
            y=y,
            z=z,
            mode='markers',
            opacity=0.9,
        )
    ]

    fig = go.Figure(data=data)
    fig.update_layout(
        title='三维散点',
        autosize=False,
        width=900,
        height=900,
        margin=dict(
            l=65,
            r=50,
            b=65,
            t=90
        )
    )

    fig.show()

如图:

发布了1029 篇原创文章 · 获赞 987 · 访问量 336万+

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/103672239
今日推荐