pgleeson commited on
Commit
d1aa2ae
·
1 Parent(s): 2da6ac8

Test pyvista

Browse files
Files changed (3) hide show
  1. app.py +24 -1
  2. packages.txt +3 -0
  3. requirements.txt +2 -1
app.py CHANGED
@@ -1,4 +1,27 @@
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
 
 
3
 
4
- st.title('Hello. world')
 
1
+
2
+ import pyvista as pv
3
  import streamlit as st
4
+ from stpyvista import stpyvista
5
+
6
+ st.title("A cube")
7
+ st.info("""Code adapted from https://docs.pyvista.org/user-guide/jupyter/pythreejs.html#scalars-support""")
8
+
9
+ ## Initialize a plotter object
10
+ plotter = pv.Plotter(window_size=[400,400])
11
+
12
+ ## Create a mesh with a cube
13
+ mesh = pv.Cube(center=(0,0,0))
14
+
15
+ ## Add some scalar field associated to the mesh
16
+ mesh['myscalar'] = mesh.points[:, 2] * mesh.points[:, 0]
17
+
18
+ ## Add mesh to the plotter
19
+ plotter.add_mesh(mesh, scalars='myscalar', cmap='bwr')
20
+
21
+ ## Final touches
22
+ plotter.view_isometric()
23
+ plotter.background_color = 'white'
24
 
25
+ ## Send to streamlit
26
+ stpyvista(plotter, key="pv_cube")
27
 
 
packages.txt CHANGED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ procps
2
+ libgl1-mesa-glx
3
+ xvfb
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  fastapi
2
- streamlit
 
 
1
  fastapi
2
+ streamlit
3
+ stpyvista