I try to understand how to plot a 3D surace from X,Y,Z real data array. So, I've found a good sample of Plotlu 3D surface plotting:
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. 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.
The simplest equation of a surface is of the form z=f(x,y). As far as I can understand, in this example, z-data
is a 2D array. 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. That is those numbers are the values of y-axis for different z
and x
. Now the question is, what z
and x
are.
The first element of z-data
( [ 0.1, 0.2, 0.3, 0.4 ]
) is for constant z=0
and different values of x
. So (x,y,z) for the first value (0.1) equals to (0,0.1,0). For second value (0.2) is (1,0.2,0) and so on.
The second element of z-data
( [ 0.5, 0.6, 0.7, 0.8 ]
) is for constant z=1
and different values of x
. So (x,y,z) for the first value (0.5) equals to (0,0.5,1). For second value (0.6) is (1,0.6,1) and so on.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.