Skip to content

[BUG] Fixing Tutorial 12 Visualizing Geological Cross Sections with PyVista #354

@JanWagner1312

Description

@JanWagner1312

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions