Comments (8)
I thought I had the panel code to only run if the code is being executed from a Jupyter notebook.
And yes, it works as expected. My bad, it was not clear. What I mean is, I had to use a workaround in my specific use case because I expect that any call to .show()
will show the renderer (c.f. plot_sphere_1()
scenario) even if it's not the cell's output.
from pyvista-support.
Do you think there would be a way to integrate such a feature in PyVista
Probably - we should add something like this in pyvista/pyvista#300. My only hesitation is that the url and port have to be known, and they might not always be notebook_url="localhost:8888"
, port=0
so maybe we should ping the panel
dev team.
Frankly, I think all notebook related dev should be paused until a few things move forward with itk-jupyter-widgets
. Reference InsightSoftwareConsortium/itkwidgets#154 and waiting on:
Once those two issues are addressed, we will favor using itk-jupyter-widgets
for notebook rendering directly instead of all the hacky solutions where a VTK render window is exported/serialized for VTKjs, X3D, or K3D.
from pyvista-support.
After more investigation I found that this version of plot_scene_1()
is way simpler and doesn't require notebook_show()
or any unnecessary tweaks anymore:
def plot_scene_1():
from IPython.display import display
S = pv.Sphere()
plotter = pv.Plotter()
plotter.add_mesh(S, color='white')
disp = plotter.show(use_panel=True, auto_close=False)
display(disp)
plot_scene_1()
from pyvista-support.
Actually if I modify plot_scene_1()
like the following, it is displayed automatically:
def plot_scene_1():
S = pv.Sphere()
plotter = pv.Plotter()
plotter.add_mesh(S)
return plotter.show()
plot_scene_1()
So I work on integrating this idea in mne-python. Please don't hesitate to tell me if you know any way to do it better.
from pyvista-support.
@GuillaumeFavelier: the plotter.show()
call is actually returning a panel.pane.vtk.VTK
object that can be displayed in the Jupyter cell output. Calling plotter.show()
and not having its result be the cell's output will result in the panel-based interactive rendering not be shown.
I expect this behavior... however this might be considered a bug as a user might expect that any call to .show()
will show the renderer. Also, this is inconsistent with a the static screenshot display in Jupyter notebooks (which returns None and displays the screenshot without it being the cells output):
from pyvista import examples
import pyvista as pv
mesh = examples.download_st_helens().warp_by_scalar()
plotter = pv.Plotter()
plotter.add_mesh(mesh)
output = plotter.show(use_panel=False)
Perhaps we need to collaborate with the panel
developers to see if there is a way to display a panel object without it being a cell's output?
from pyvista-support.
Many thanks for the detailed explanations @banesullivan, now I understand better how it works and I think I can manage with this solution for now. Although I had to rely on the part of code detecting if the script is executed inside a notebook.
Perhaps we need to collaborate with the panel developers to see if there is a way to display a panel object without it being a cell's output?
That would wonderful of course!
from pyvista-support.
Although I had to rely on the part of code detecting if the script is executed inside a notebook.
That's strange, what exactly do you mean? I thought I had the panel
code to only run if the code is being executed from a Jupyter notebook.
from pyvista-support.
Actually after some more research I found a way to force panel to show the pane thanks to the show_server()
function:
So I used the following function:
def notebook_show(disp, notebook_url="localhost:8888", port=0):
from panel.viewable import show_server
show_server(disp, notebook_url, port)
Do you think there would be a way to integrate such a feature in PyVista @banesullivan ? Eventually, I can open a discussion with the Panel developers to find a better/cleaner solution just in case.
from pyvista-support.
Related Issues (20)
- create uniform mesh HOT 3
- Change the orientation of a scalar bar's title
- Applying textures on models from .obj files HOT 6
- How to create an Unstructured grid from points and faces HOT 2
- Type of data, plotting with glyphs HOT 3
- Controlling the thickness and orientation of a slice in Pyvista HOT 3
- Controlling the image position in window, without any click
- Mask/Remove Voxels in Air (small intersection with surface) HOT 3
- custom slider parameters
- running pyvista on headless machine with Centos OS HOT 1
- Seismic Horizon with Pyvista HOT 8
- Algorithm in sample function?
- Automatically updates HOT 3
- Slow interaction HOT 1
- read from text HOT 4
- Uniform Grid thresholding question HOT 8
- Take data by an input x,y,x coordinate (csv file) from vtk data file HOT 4
- Program broke when creating a mesh using pv.PolyData() HOT 4
- ATTENTION: Please move questions to PyVista's Discussions HOT 1
- plotter.enable_terrain_style not working for me HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvista-support.