Skip to content

Mesh Scalar Assign Tutorial Does Not Render #449

@SpicyRicecaker

Description

@SpicyRicecaker

Describe the bug, what's wrong, and what you expect:

The visualization for the mesh at https://tutorial.pyvista.org/tutorial/02_mesh/index.html#assigning-scalars-to-a-mesh seems to be bugged


To Reproduce

Go to https://tutorial.pyvista.org/tutorial/02_mesh/index.html#assigning-scalars-to-a-mesh, and look at the static result of the render, or try to render the dynamic scene.

Or, attempt to render the scene locally using the snippet of code provided in the tutorial:

import pyvista as pv

cube = pv.Cube()
cube.cell_data['myscalars'] = range(6)

other_cube = cube.copy()
other_cube.point_data['myscalars'] = range(8)

pl = pv.Plotter(shape=(1, 2), border_width=1)
pl.add_mesh(cube, cmap='coolwarm')
pl.subplot(0, 1)
pl.add_mesh(other_cube, cmap='coolwarm')
pl.show()

Screenshots

Image
Image


System Information:

--------------------------------------------------------------------------------
  Date: Sat Mar 22 23:29:02 2025 PDT

                  OS : Darwin (macOS 15.3)
              CPU(s) : 8
             Machine : arm64
        Architecture : 64bit
                 RAM : 8.0 GiB
         Environment : Jupyter
         File system : apfs
          GPU Vendor : Apple
        GPU Renderer : Apple M1
         GPU Version : 4.1 Metal - 89.3
    MathText Support : True

  Python 3.13.1 (main, Dec 19 2024, 14:22:59) [Clang 18.1.8 ]

             pyvista : 0.44.1
                 vtk : 9.4.1
               numpy : 2.2.4
          matplotlib : 3.10.1
              scooby : 0.10.0
               pooch : 1.8.2
              pillow : 11.1.0
             imageio : 2.37.0
             IPython : 9.0.2
            colorcet : 3.1.0
             cmocean : 4.0.3
          ipywidgets : 8.1.5
               scipy : 1.15.2
              meshio : 5.3.5
               trame : 3.8.1
        trame_client : 3.6.0
        trame_server : 3.4.0
           trame_vtk : 2.8.15
       trame_vuetify : 2.8.1
jupyter_server_proxy : 4.4.0
        nest_asyncio : 1.6.0
--------------------------------------------------------------------------------

fix ideas

I tried replacing range(n) with arange(n, dtype=float), and this seems to completely fix the render. I wonder if pyvista has trouble normalizing non-float scalars.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions