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

nan_color ignored from VTK panel==1.4.1 after exporting to HTML #6730

Closed
edsaac opened this issue Apr 15, 2024 · 1 comment · Fixed by #6763
Closed

nan_color ignored from VTK panel==1.4.1 after exporting to HTML #6730

edsaac opened this issue Apr 15, 2024 · 1 comment · Fixed by #6763
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@edsaac
Copy link

edsaac commented Apr 15, 2024

Description of expected behavior and the observed behavior

Cells with NaN values should be colored according to the provided nan_color kwarg. However, they always default to a redish color. I believe this is a follow up from #6627, where the color mapping was fixed, except for handling NaN colors.

Screenshots or screencasts of the bug in action

No bug Bug
image image

Software version info

No bug Bug
panel==1.3.8 panel==1.4.1
bokeh==3.3.4 bokeh==3.4.1
pyvista==0.43.5 pyvista==0.43.5

Complete, minimal, self-contained example code that reproduces the issue

import pyvista as pv
import panel as pn
import numpy as np
pn.extension("vtk")

## Initialize a plotter object
plotter = pv.Plotter(window_size=[400, 400])

## Create a mesh
mesh = pv.Sphere(radius=1.0)

## Associate a scalar field to the mesh
z = mesh.cell_centers().points.T[2]
mesh["myscalar"] = np.where(z < 0.7, z, np.nan)

## Add mesh to the plotter
plotter.add_mesh(
    mesh, scalars="myscalar", cmap="viridis", show_edges=True, nan_color="magenta"
)

## Some final touches
plotter.background_color = "white"
plotter.view_isometric()
plotter.add_title(f"Using panel=={pn.__version__}")

## Pass plotter to panel
sphere_pan = pn.panel(plotter.ren_win, width=400, orientation_widget=True)

## Export as HTML
with open(f"sphere_pan_{pn.__version__}.html", 'w') as f:
    sphere_pan.save(f)

Stack traceback and/or browser JavaScript console output

With panel==1.4.1:

[bokeh 3.4.1] [bokeh-3.4.1.min.js:166:1469](https://cdn.bokeh.org/bokeh/release/bokeh-3.4.1.min.js) WebGL warning: getParameter: Framebuffer not complete. (status: 0x8cd7)
@philippjfr philippjfr added this to the v1.4.2 milestone Apr 15, 2024
@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Apr 15, 2024
@edsaac
Copy link
Author

edsaac commented Apr 15, 2024

This is perhaps related: the above_color and below_color values are also ignored.

No bug Bug
image image
Code:
import pyvista as pv
import panel as pn

pn.extension("vtk")

## Initialize a plotter object
plotter = pv.Plotter(window_size=[400, 400])

## Create a mesh
mesh = pv.Sphere(radius=1.0)

## Associate a scalar field to the mesh
z = mesh.cell_centers().points.T[2]
mesh["myscalar"] = z 

## Add mesh to the plotter
plotter.add_mesh(
    mesh,
    scalars="myscalar",
    cmap="viridis",
    show_edges=True,
    clim=[-0.5, 0.5],
    above_color="magenta",
    below_color="orange",
)

## Some final touches
plotter.background_color = "white"
plotter.view_isometric()
plotter.add_title(f"Using panel=={pn.__version__}")

## Pass a plotter to panel
sphere_pan = pn.panel(plotter.ren_win, width=400, orientation_widget=True)

## Export as HTML
with open(f"sphere_pan_{pn.__version__}.html", 'w') as f:
    sphere_pan.save(f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants