1

I have a scatter plot of a 3D point cloud (see picture). The green points actually form an extrusion in the shape of a star, the blue is a pentagon etc, but this is very difficult to see. So I would like to have some "shading" of the point clouds. It's possible to do this sort of thing for surfaces (like discussed here:

The code I have currently:

import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()  # for plot styling

filename = sys.argv[1]
# flow_events = np.loadtxt(filename, comments='#')
flow_events = pd.read_csv(filename, delimiter = "\t", skiprows=1, names=["event_x", "event_y", "event_ts", "event_label"])
n_flow_events = flow_events.values

# start = int(n_flow_events.shape[0]/3.0)
end = int(n_flow_events.shape[0]/10.0*7)
start = 0
# end = n_flow_events.shape[0]

events = n_flow_events[start:end, :]

number_to_display = 5
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(events[0::number_to_display, 0], events[0::number_to_display, 1], events[0::number_to_display, 2], c=(events[0::number_to_display, 3]+4), s=4, cmap=plt.cm.brg)

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('time [s]')

plt.show()

The point cloud

Rarblack
  • 4,559
  • 4
  • 22
  • 33
Mr Squid
  • 1,196
  • 16
  • 34
  • The blog post you linked to shows the shading of the surface defined by a *function*. I.e., for every `(x,y)` input, there is a *single* `z`. Your data are not like this, and defining these types of surfaces is much trickier in plotting libraries that are meant for displaying data. What you're hoping to show would be better suited to a 3D modeling program. – PMende Oct 26 '18 at 17:49
  • 2
    I'd add to this plot points on the top and bottom that are co-located at the ends but in a slightly different color. You can change the edgecolors as well https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html – mauve Oct 26 '18 at 17:50
  • probably the easiest thing to do would be to export your data to a `.ply` file then search around for methods to convert `.ply` to `.stl` (a common operation for people 3d scanning objects into stl files). You can then open the `stl` file in something like meshlab which should perform appropriate lighting rendering. – Aaron Oct 26 '18 at 17:58

1 Answers1

0

So this is not exactly a solution to the question I asked, but I ended up doing what mauve suggested: Point cloud caps in black

Mr Squid
  • 1,196
  • 16
  • 34