isl-org / isl-org/Open3D

Difference between matplotlib.pyplot and Open3D point clouds visualization in Z-axis

Open
#6,674 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### My Question

I have a question why the two libraries produce the different image of the same point cloud. The difference is in the Z-axis visualization — points (in the example below lines) have different distance, but the dataset is the same.

I can understand it, because X and Y coordinates are much lower, than for Z (file attached). So, my question is how to achieve the same picture in the Open3D — maybe you already have some generic solution for it? I just figured out how to make it manually, reducing the Z-coordinate multiplying it (commented line of code in the MRE).

```py
import matplotlib.pyplot as plt
import numpy as np
import open3d as o3d

pc_matrix = np.genfromtxt("matrix8-10.csv", delimiter=",")

# Matplotlib
x, y, z = pc_matrix[:, 0], pc_matrix[:, 1], pc_matrix[:, 2]
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection="3d")
ax.scatter(x, y, z)
plt.show()

# Open3D
pcd = o3d.geometry.PointCloud()

# this reduces all the values of Z-axis (uncomment this line for see the desired picture)
# pc_matrix = [[point[0], point[1], point[2] * 0.3] for point in pc_matrix]

pcd.points = o3d.utility.Vector3dVector(pc_matrix)
pcd.colors = o3d.utility.Vector3dVector([[0, 0, 255] for point in pc_matrix])

visualizer = o3d.visualization.Visualizer()
visualizer.create_window()
visualizer.add_geometry(pcd)
render_option = visualizer.get_render_option()
render_option.background_color = [0, 0, 0]
visualizer.run()
```

So, this code produce following visualizations:
![matplotlib-rectangle](https://github.com/isl-org/Open3D/assets/45794357/fee22006-da25-4d06-ad4f-e64259c327da)
![open3d-rectangle](https://github.com/isl-org/Open3D/assets/45794357/ec879e07-7591-4ab7-bd1e-7600b467ef3b)

But, the desired image in Open3D is:
![open3d-z-reduced-rectangle](https://github.com/isl-org/Open3D/assets/45794357/6c31c37d-6022-4533-919f-6bde85f96ade)

The dataset I used for the visualization:
[matrix8-10.csv](https://github.com/isl-org/Open3D/files/14461851/matrix8-10.csv)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.