forked from kuixu/kitti_object_vis
/
scatter_plot.py
42 lines (34 loc) · 1.02 KB
/
scatter_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 15:54:37 2020
@author: james
"""
import numpy as np
from tvtk.api import tvtk
from mayavi.scripts import mayavi2
@mayavi2.standalone
def main():
# Create some random points to view.
pd = tvtk.PolyData()
pd.points = np.random.random((1000, 3))
verts = np.arange(0, 1000, 1)
verts.shape = (1000, 1)
pd.verts = verts
pd.point_data.scalars = np.random.random(1000)
pd.point_data.scalars.name = 'scalars'
# Now visualize it using mayavi2.
from mayavi.sources.vtk_data_source import VTKDataSource
from mayavi.modules.outline import Outline
from mayavi.modules.surface import Surface
mayavi.new_scene()
d = VTKDataSource()
d.data = pd
mayavi.add_source(d)
mayavi.add_module(Outline())
s = Surface()
mayavi.add_module(s)
s.actor.property.trait_set(representation='p', point_size=2)
# You could also use glyphs to render the points via the Glyph module.
if __name__ == '__main__':
main()