-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathplot_test.py
More file actions
30 lines (24 loc) · 786 Bytes
/
plot_test.py
File metadata and controls
30 lines (24 loc) · 786 Bytes
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
from plotter import *
import numpy as np
from scipy.interpolate import interp2d
import pyvista as pv
import mpl_toolkits.mplot3d
import matplotlib.pyplot as plt
a = DataPlotter('PLOTCON')
x = a.data[:, 0]
y = a.data[:, 1]
z = a.data[:, 2]
interpfunc = interp2d(x, y, z)
newx = np.linspace(0, np.max(x), 1000)
newy = np.linspace(0, np.max(y), 1000)
newz = interpfunc(newx, newy)
# PyVista surface plot
nx, ny = len(newx), len(newy)
X, Y = np.meshgrid(newx, newy, indexing='ij')
Z = newz.T
surface = pv.StructuredGrid(X[:, :, None], Y[:, :, None], Z[:, :, None])
surface.point_data['scalars'] = Z[:, :, None].flatten(order='F')
pl = pv.Plotter()
pl.add_mesh(surface, scalars='scalars', cmap='viridis', show_scalar_bar=True)
pl.add_axes(xlabel='x', ylabel='y', zlabel='z')
pl.show()