Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Tutorial 12 Visualizing Geological Cross Sections with PyVista #354

Open
JanWagner1312 opened this issue Oct 11, 2024 · 0 comments
Open

Comments

@JanWagner1312
Copy link

JanWagner1312 commented Oct 11, 2024

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)

@JanWagner1312 JanWagner1312 changed the title [BUG] Fixing Tutorial 12 Visualizing Geological Cross Sections with PyVista Fixing Tutorial 12 Visualizing Geological Cross Sections with PyVista Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant