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

Coloration abnormalities #19

Closed
Bobosaver opened this issue Apr 1, 2024 · 8 comments
Closed

Coloration abnormalities #19

Bobosaver opened this issue Apr 1, 2024 · 8 comments

Comments

@Bobosaver
Copy link

I want to color my VTK image.If I key "plotter.show()", it did great.But in stpyvista , there is an abnormality in the color.

image
image

@edsaac
Copy link
Owner

edsaac commented Apr 1, 2024

I noticed that and it seems like a regression on the latest version of panel. Setting its version to panel==1.3.8 should work for now.

@Bobosaver
Copy link
Author

Thanks, problem solved. I set panel==1.3.2,It shows the right thing too.,But panel==1.4.0 may occur error. Thanks for your answer.

@Bobosaver
Copy link
Author

But, a new error occur. it can not show my VTk, just a output word.
image

@edsaac
Copy link
Owner

edsaac commented Apr 2, 2024

I have seen that occasionally when running Python<=3.9, and it is part of the reason Python >= 3.10 is recommended. What version of Python are you running?

@Bobosaver
Copy link
Author

I use anaconda ,and my python==3.10.13. And I met another problem, after I upgrade my python to 3.11.7 ,
def plot_orthogonal(mesh,size,u,v,w):
slices = mesh.slice_orthogonal(x=u, y=v, z=w)
plotter = pv.Plotter(window_size=size)
plotter.add_mesh(slices,cmap="jet")
plotter.background_color = "white"
# plotter.camera.zoom('tight')
# plotter.view_isometric()
return plotter

web can not show vtk_slice(but Overall vtk show right).
image

@edsaac
Copy link
Owner

edsaac commented Apr 2, 2024

slices = mesh.slice_orthogonal(x=u, y=v, z=w)

slice_orthogonal returns a pv.MultiBlock object, which is basically a bundle of meshes. Iterating over the MultiBlock and adding each mesh individually to the plotter will do the trick.

image


This is a nice example that could go in the Discussion section in this repo.

import pyvista as pv
from pyvista import examples
import streamlit as st
from stpyvista import stpyvista

pv.start_xvfb()

mesh = examples.load_channels()
add_mesh_kwargs = dict(cmap="copper", ambient=0.5)

## App layout
st.title("🍕 Slices & stpyvista")
cols = st.columns(2)

with cols[0]:
    "## Full 3D model"
    pl = pv.Plotter()
    pl.window_size = [300, 300]
    pl.add_mesh(mesh, **add_mesh_kwargs)
    pl.add_axes()
    pl.view_isometric()

    stpyvista(pl)

with cols[1]:
    "## Orthogonal slices"
    slices = mesh.slice_orthogonal(x=50, y=50, z=30)
    slices_pl = pv.Plotter()
    slices_pl.window_size = [300, 300]

    for slice in slices:
        slices_pl.add_mesh(slice, **add_mesh_kwargs)

    slices_pl.add_axes()
    slices_pl.view_isometric()
    stpyvista(slices_pl)

@edsaac edsaac mentioned this issue Apr 2, 2024
@Bobosaver
Copy link
Author

thanks anyway,I will try it.

@edsaac
Copy link
Owner

edsaac commented Apr 9, 2024

Updating to panel>=1.4.1 will solve the colormap issue.

holoviz/panel#6627

@edsaac edsaac closed this as completed Apr 9, 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

2 participants