반응형
import pickle
# Load tensor from the file
with open('tensor.pkl', 'rb') as f:
loaded_tensor = pickle.load(f)
grids = loaded_tensor[0] # num_cams x num_depth x H x W x 3
grids = grids.view(-1, 3).to('cpu').numpy()
import plotly.graph_objects as go
# Sample data: sequence of 3D points (x, y, z)
x_points = list(grids[:, 0])
y_points = list(grids[:, 1])
z_points = list(grids[:, 2])
# Create a 3D scatter plot using plotly
fig = go.Figure(data=[go.Scatter3d(
x=x_points,
y=y_points,
z=z_points,
mode='markers+lines', # You can use 'markers', 'lines' or 'markers+lines'
marker=dict(
size=8,
color=z_points, # Color by the z values
colorscale='Viridis', # Choose a color scale
colorbar=dict(title="Z Values")
),
line=dict(
color='blue',
width=2
)
)])
# Set plot layout and axis labels
fig.update_layout(scene=dict(
xaxis_title='X Axis',
yaxis_title='Y Axis',
zaxis_title='Z Axis'),
title="3D Plot of a Sequence of Points"
)
# Show the plot
fig.show()
'Python' 카테고리의 다른 글
Scatter plot with subfigures (0) | 2023.11.13 |
---|---|
현재 모델의 state_dict()가 갖는 key값만 저장된 state_dict()로 부터 불러오기 (0) | 2023.06.02 |
PIL.image 라이브러리 사용법 (0) | 2023.05.31 |
Change working directory to current location (0) | 2023.05.18 |
nuScenes 데이터셋의 이해 (0) | 2023.05.12 |