question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jittery Scalar Bar in Saved GIF

See original GitHub issue

Bug Description:

When creating a GIF and rendering it onscreen, the scalar bar’s color map shows a smooth color gradient. However, after the animation is saved, the color gradient becomes blocky and jittery.

This appears to be an issue with either a new version of PyVista or a new version of one of its dependencies (potentially VTK). I believe this because I have previously saved GIF files that show a smooth scalar bar. However, I’ve been unsuccessful in pinpointing which version of PyVista or its dependencies causes the issues.


To Reproduce

The following code snippet is copied verbatim from the Create a GIF Movie page on the documentation. I also thought that the issue might be my graphics card drivers, but the example GIF displayed in the documentation also appears to suffer from the same problem.

import numpy as np

import pyvista as pv

x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x ** 2 + y ** 2)
z = np.sin(r)

# Create and structured surface
grid = pv.StructuredGrid(x, y, z)

# Create a plotter object and set the scalars to the Z height
plotter = pv.Plotter(notebook=False, off_screen=True)
plotter.add_mesh(grid, scalars=z.ravel(), smooth_shading=True)

# Open a gif
plotter.open_gif("wave.gif")

pts = grid.points.copy()

# Update Z and write a frame for each updated position
nframe = 15
for phase in np.linspace(0, 2 * np.pi, nframe + 1)[:nframe]:
    z = np.sin(r + phase)
    pts[:, -1] = z.ravel()
    plotter.update_coordinates(pts, render=False)
    plotter.update_scalars(z.ravel(), render=False)

    # must update normals when smooth shading is enabled
    plotter.mesh.compute_normals(cell_normals=False, inplace=True)
    plotter.render()
    plotter.write_frame()

# Closes and finalizes movie
plotter.close()

Screenshots Jittery Scalar Bar PyVista==0.30.0, VTK==9.0.3: wave_pyvista_0 30 0_vtk_9 0 3

PyVista==0.33.2, VTK==9.0.0: wave_pyvista_0 33 2_vtk_9 0 0

PyVista==0.33.2, VTK==9.0.3: wave_pyvista_0 33 2_vtk_9 0 3

PyVista==0.33.2, VTK==9.1.0: wave_pyvista_0 33 2_vtk_9 1 0

Smooth Scalar Bar Animation Made A Few Months Ago Using Different Code (PyVista and VTK Versions Unknown): Animate Output


System Information:

--------------------------------------------------------------------------------
  Date: Wed Jan 26 11:08:26 2022 Eastern Standard Time
                OS : Windows
            CPU(s) : 8
           Machine : AMD64
      Architecture : 64bit
       Environment : Python
       File system : unknown
        GPU Vendor : Intel
      GPU Renderer : Intel(R) HD Graphics P530
       GPU Version : 4.5.0 - Build 27.20.100.8681
  Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit
  (AMD64)]
           pyvista : 0.33.2
               vtk : 9.1.0
             numpy : 1.22.1
           imageio : 2.14.1
           appdirs : 1.4.4
            scooby : 0.5.11
        matplotlib : 3.5.1
--------------------------------------------------------------------------------

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
akaszynskicommented, Jan 27, 2022

These are some amazing gifs. @tkoyama010, could you add camUrban/PteraSoftware as an external example?

I’ve been thinking about streamlining how we do animation anyway, this might be a good example to base the PR off of.

1reaction
tkoyama010commented, Jan 29, 2022

These are some amazing gifs. @tkoyama010, could you add camUrban/PteraSoftware as an external example?

Yes. Let’s add it. Note: https://github.com/camUrban/PteraSoftware

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a GIF Movie — PyVista 0.37.0 documentation
Generate a moving gif from an active plotter. ... Use lighting=False to reduce the size of the color space to avoid “jittery” GIFs,...
Read more >
Animated GIF wih Annotations. Annoying Bar on the side
Only the output GIF has an annoying bar on the right side which changes with every frame of the GIF. See picture below:...
Read more >
Ape drink gif # - Market Show of Best Club crypto NFT - OpenSea
... they excited see sloth peter road kill excellent save money dinner stench ... nomnom cookies icecream sweettooth drinkup pub bar beer beers...
Read more >
3D Slicer Documentation - Read the Docs
Color legend (or color bar, scalar bar): a widget overlaid on slice or 3D views that ... Animated GIF (grayscale): animated GIF, saved...
Read more >
Gnuplot 5.2
252) terminal supports saving the current graph to a bitmap file ... Font handling for the png, gif, jpeg, and sixelgd terminals is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found