gemgis
gemgis copied to clipboard
[BUG] Fixing Tutorial 12 Visualizing Geological Cross Sections with PyVista
Describe the bug Under "Adding texture to mesh", the texture is rotated in the wrong direction.
Additional context This code should deliver a solution:
from matplotlib.pyplot import get_cmap
create an image using numpy,
zz = grid['values'].reshape(1201,662)
Creating a custom RGB image
cmap = cmap_seismic #get_cmap("nipy_spectral") norm = lambda x: (x - np.nanmin(x)) / (np.nanmax(x) - np.nanmin(x)) hue = norm(zz.ravel()) colors = (cmap(hue)[:, 0:3] * 255.0).astype(np.uint64) image = colors.reshape((1201, 662, 3), order="F")
Convert 3D numpy array to texture
tex = pv.numpy_to_texture(image)
Render it
grid.plot(texture=tex)