简体   繁体   English

如何从 Plotly 中的 X、Y、Z 数组绘制 3D 表面?

[英]How to plot a 3D surface from X,Y,Z array in Plotly?

I try to understand how to plot a 3D surace from X,Y,Z real data array.我试图了解如何从 X、Y、Z 真实数据数组绘制 3D 曲面。 So, I've found a good sample of Plotlu 3D surface plotting:所以,我找到了一个很好的 Plotlu 3D 曲面绘图示例:

import plotly.graph_objects as go

import pandas as pd

# Read data from a csv
z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')

fig = go.Figure(data=[go.Surface(z=z_data.values)])

fig.update_layout(title='Mt Bruno Elevation', autosize=False,
                  width=500, height=500,
                  margin=dict(l=65, r=50, b=65, t=90))

fig.show()

But, mt_bruno_elevation.csv data is a bit confusing for me.但是,mt_bruno_elevation.csv 数据对我来说有点混乱。 I don't understand what exactly data represents in csv and how to build something similar if I have an X,Y,Z array of my real data.我不明白数据在 csv 中究竟代表什么,以及如果我有一个真实数据的 X、Y、Z 数组,如何构建类似的东西。

The simplest equation of a surface is of the form z=f(x,y).最简单的曲面方程的形式为 z=f(x,y)。 As far as I can understand, in this example, z-data is a 2D array.据我所知,在这个例子中, z-data是一个二维数组。 Take a look at below example;看看下面的例子;

 z-data = [ 
[ 0.1, 0.2, 0.3, 0.4 ],
[ 0.5, 0.6, 0.7, 0.8 ],
[ 0.9, 1.0, 1.1, 1.2 ],
[ 1.3, 1.4, 1.5, 1.6 ]
]

This is a z-matrix.这是一个 z 矩阵。 That is those numbers are the values of y-axis for different z and x .也就是说,这些数字是不同zx的 y 轴值。 Now the question is, what z and x are.现在的问题是, zx是什么。

The first element of z-data ( [ 0.1, 0.2, 0.3, 0.4 ] ) is for constant z=0 and different values of x . z-data的第一个元素( [ 0.1, 0.2, 0.3, 0.4 ] )用于常量z=0和不同的x值。 So (x,y,z) for the first value (0.1) equals to (0,0.1,0).因此,第一个值 (0.1) 的 (x,y,z) 等于 (0,0.1,0)。 For second value (0.2) is (1,0.2,0) and so on.对于第二个值 (0.2) 是 (1,0.2,0) 等等。

The second element of z-data ( [ 0.5, 0.6, 0.7, 0.8 ] ) is for constant z=1 and different values of x . z-data的第二个元素 ( [ 0.5, 0.6, 0.7, 0.8 ] ) 用于常量z=1和不同的x值。 So (x,y,z) for the first value (0.5) equals to (0,0.5,1).所以第一个值 (0.5) 的 (x,y,z) 等于 (0,0.5,1)。 For second value (0.6) is (1,0.6,1) and so on.对于第二个值 (0.6) 是 (1,0.6,1) 等等。

Helpful links: Link 1 Link 2 Link 3有用的链接: 链接 1 链接 2链接 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM