Färben Sie eine Oberfläche mit MESH3D in Python PlotlyPython

Python-Programme
Anonymous
 Färben Sie eine Oberfläche mit MESH3D in Python Plotly

Post by Anonymous »

Ich ziele darauf ab, eine Oberfläche in einem 3D -Diagramm zu färben, das mit Plotly erstellt wurde. Wie kann dies in Plotly gelöst werden ?
Das endgültige Ergebnis sollte diesem Beispiel ähnlich sein:

Das Ziel ist es, die Oberfläche zu färben, an der die vertikalen Linien die beiden Kurven verbinden (d. H. Eine 3-dimensionale Kurve und ihre Projektion auf die X-y-Ebene). /> Hier ist mein Code: < /p>

Code: Select all

import pandas as pd
import plotly.graph_objects as go
import numpy as np

data = pd.read_excel(r"")

x = data['x'].values
y = data['y'].values
z = data['alt'].values

z_min_adjusted = np.maximum(z, 350)

def plot_3d_course_profile(x, y, z, color_attribute, colorbar_label):
fig = go.Figure()

# Projection at z = 350
fig.add_trace(go.Scatter3d(
x=x,
y=y,
z=[350] * len(x),
mode='lines',
line=dict(
color='black',
width=5,
)
))

# Profile curve
fig.add_trace(go.Scatter3d(
x=x,
y=y,
z=z,
mode='lines',
line=dict(
color=color_attribute,
width=13,
colorscale='Jet',
colorbar=dict(
title=dict(
text=colorbar_label,
font=dict(size=14, color='black')
),
thickness=20,
len=0.6,
tickfont=dict(size=12, color='black'),
tickmode='linear',
tickformat='.2f',
outlinewidth=1,
outlinecolor='black'
)
)
))

# Vertical lines
for i in range(0, len(x), 20):
xi, yi, zi = x[i], y[i], z[i]
fig.add_trace(go.Scatter3d(
x=[xi, xi],
y=[yi, yi],
z=[350, zi],
mode='lines',
line=dict(color='dimgray', width=4),
opacity=0.6,
showlegend=False
))

#Layout
fig.update_layout(
template='plotly_white',
scene=dict(
xaxis=dict(title='Meters north from start position', showgrid=True, gridcolor='lightblue', zeroline=False),
yaxis=dict(title='Meters east from start position', showgrid=True, gridcolor='lightblue', zeroline=False),
zaxis=dict(title='Altitude [m]', showgrid=True, gridcolor='lightblue', zeroline=False),
aspectmode='manual',
aspectratio=dict(x=1.25, y=1, z=0.7)
),
title=f'{colorbar_label}',
margin=dict(l=0, r=0, b=0, t=50)
)

fig.show()

plot_3d_course_profile(x, y, z_min_adjusted, z_min_adjusted, 'Altitude [m]')

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post