本文整理汇总了Python中pyvista.Plotter方法的典型用法代码示例。如果您正苦于以下问题:Python pyvista.Plotter方法的具体用法?Python pyvista.Plotter怎么用?Python pyvista.Plotter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvista
的用法示例。
在下文中一共展示了pyvista.Plotter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_subdivisions
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def plot_subdivisions(mesh, a, b):
display_args = dict(show_edges=True, color=True)
p = pv.Plotter(shape=(3,3))
for i in range(3):
p.subplot(i,0)
p.add_mesh(mesh, **display_args)
p.add_text("Original Mesh")
def row_plot(row, subfilter):
subs = [a, b]
for i in range(2):
p.subplot(row, i+1)
p.add_mesh(mesh.subdivide(subs[i], subfilter=subfilter), **display_args)
p.add_text("{} subdivision of {}".format(subfilter, subs[i]))
row_plot(0, "linear")
row_plot(1, "butterfly")
row_plot(2, "loop")
p.link_views()
p.view_isometric()
return p
###############################################################################
# Run the subdivisions for 1 and 3 levels.
示例2: plot_example
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def plot_example():
p = pv.Plotter()
p.add_mesh(mesh)
p.add_bounding_box()
return p.show()
###############################################################################
# PyVista's default color theme is chosen to be generally easy on your eyes
# and is best used when working long hours on your visualization project.
# The grey background and warm colormaps are chosen to make sure 3D renderings
# do not drastically change the brightness of your screen when working in dark
# environments.
#
# Here's an example of our default plotting theme - this is what you would see
# by default after running any of our examnples.
示例3: test_widget_box
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_widget_box():
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda box: box # Does nothing
p.add_mesh(mesh)
p.add_box_widget(callback=func)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda box, widget: box # Does nothing
p.add_mesh(mesh)
p.add_box_widget(callback=func, pass_widget=True)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh_clip_box(mesh)
p.close()
示例4: test_widget_line
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_widget_line():
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda line: line # Does nothing
p.add_mesh(mesh)
p.add_line_widget(callback=func)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda line, widget: line # Does nothing
p.add_mesh(mesh)
p.add_line_widget(callback=func, pass_widget=True)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda a, b: (a, b) # Does nothing
p.add_mesh(mesh)
p.add_line_widget(callback=func, use_vertices=True)
p.close()
示例5: test_widget_spline
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_widget_spline():
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda spline: spline # Does nothing
p.add_mesh(mesh)
p.add_spline_widget(callback=func)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
func = lambda spline, widget: spline # Does nothing
p.add_mesh(mesh)
p.add_spline_widget(callback=func, pass_widget=True, color=None, show_ribbon=True)
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh_slice_spline(mesh)
p.close()
示例6: test_plot_show_bounds
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_plot_show_bounds():
plotter = pyvista.Plotter(off_screen=OFF_SCREEN)
plotter.add_mesh(sphere)
plotter.show_bounds(show_xaxis=False,
show_yaxis=False,
show_zaxis=False,
show_xlabels=False,
show_ylabels=False,
show_zlabels=False,
use_2d=True)
# And test backwards compatibility
plotter.add_bounds_axes(show_xaxis=False,
show_yaxis=False,
show_zaxis=False,
show_xlabels=False,
show_ylabels=False,
show_zlabels=False,
use_2d=True)
plotter.show()
示例7: test_set_background
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_set_background():
plotter = pyvista.Plotter(off_screen=OFF_SCREEN)
plotter.set_background('k')
plotter.background_color = "yellow"
plotter.set_background([0, 0, 0], top=[1,1,1]) # Gradient
_ = plotter.background_color
plotter.show()
plotter = pyvista.Plotter(off_screen=OFF_SCREEN, shape=(1,2))
plotter.set_background('orange')
for renderer in plotter.renderers:
assert renderer.GetBackground() == pyvista.parse_color('orange')
plotter.show()
plotter = pyvista.Plotter(off_screen=OFF_SCREEN, shape=(1,2))
plotter.subplot(0,1)
plotter.set_background('orange', all_renderers=False)
assert plotter.renderers[0].GetBackground() != pyvista.parse_color('orange')
assert plotter.renderers[1].GetBackground() == pyvista.parse_color('orange')
plotter.show()
示例8: test_screenshot
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_screenshot(tmpdir):
plotter = pyvista.Plotter(off_screen=True)
plotter.add_mesh(pyvista.Sphere())
img = plotter.screenshot(transparent_background=True)
assert np.any(img)
img_again = plotter.screenshot()
assert np.any(img_again)
filename = str(tmpdir.mkdir("tmpdir").join('export-graphic.svg'))
plotter.save_graphic(filename)
# checking if plotter closes
ref = proxy(plotter)
plotter.close()
try:
ref
except:
raise RuntimeError('Plotter did not close')
示例9: test_plot_rgb
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_plot_rgb():
""""Test adding a texture to a plot"""
cube = pyvista.Cube()
cube.clear_arrays()
x_face_color = (255, 0, 0)
y_face_color = (0, 255, 0)
z_face_color = (0, 0, 255)
face_colors = np.array([x_face_color,
x_face_color,
y_face_color,
y_face_color,
z_face_color,
z_face_color,
], dtype=np.uint8)
cube.cell_arrays['face_colors'] = face_colors
plotter = pyvista.Plotter(off_screen=OFF_SCREEN)
plotter.add_mesh(cube, scalars='face_colors', rgb=True)
plotter.show()
示例10: test_subplot_groups
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_subplot_groups():
plotter = pyvista.Plotter(shape=(3,3), groups=[(1,[1,2]),(np.s_[:],0)])
plotter.subplot(0,0)
plotter.add_mesh(pyvista.Sphere())
plotter.subplot(0,1)
plotter.add_mesh(pyvista.Cube())
plotter.subplot(0,2)
plotter.add_mesh(pyvista.Arrow())
plotter.subplot(1,1)
plotter.add_mesh(pyvista.Cylinder())
plotter.subplot(2,1)
plotter.add_mesh(pyvista.Cone())
plotter.subplot(2,2)
plotter.add_mesh(pyvista.Box())
# Test group overlap
with pytest.raises(AssertionError):
# Partial overlap
pyvista.Plotter(shape=(3,3),groups=[([1,2],[0,1]),([0,1],[1,2])])
with pytest.raises(AssertionError):
# Full overlap (inner)
pyvista.Plotter(shape=(4,4),groups=[(np.s_[:],np.s_[:]),([1,2],[1,2])])
with pytest.raises(AssertionError):
# Full overlap (outer)
pyvista.Plotter(shape=(4,4),groups=[(1,[1,2]),([0,3],np.s_[:])])
示例11: test_link_views
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_link_views():
plotter = pyvista.Plotter(shape=(1, 4), off_screen=OFF_SCREEN)
sphere = pyvista.Sphere()
plotter.subplot(0, 0)
plotter.add_mesh(sphere, smooth_shading=False, show_edges=False)
plotter.subplot(0, 1)
plotter.add_mesh(sphere, smooth_shading=True, show_edges=False)
plotter.subplot(0, 2)
plotter.add_mesh(sphere, smooth_shading=False, show_edges=True)
plotter.subplot(0, 3)
plotter.add_mesh(sphere, smooth_shading=True, show_edges=True)
with pytest.raises(TypeError):
plotter.link_views(views='foo')
plotter.link_views([0, 1])
plotter.link_views()
with pytest.raises(TypeError):
plotter.unlink_views(views='foo')
plotter.unlink_views([0, 1])
plotter.unlink_views(2)
plotter.unlink_views()
plotter.show()
示例12: test_image_properties
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_image_properties():
mesh = examples.load_uniform()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh)
p.show(auto_close=False) # DO NOT close plotter
# Get RGB image
_ = p.image
# Get the depth image
_ = p.get_image_depth()
p.close()
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh)
p.store_image = True
assert p.store_image is True
p.show() # close plotter
# Get RGB image
_ = p.image
# Get the depth image
_ = p.get_image_depth()
p.close()
示例13: test_opacity_by_array
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_opacity_by_array():
mesh = examples.load_uniform()
# Test with opacity array
mesh['opac'] = mesh['Spatial Point Data'] / 100.
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh, scalars='Spatial Point Data', opacity='opac',)
p.show()
# Test with uncertainty array (transparency)
mesh['unc'] = mesh['Spatial Point Data']
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh, scalars='Spatial Point Data', opacity='unc',
use_transparency=True)
p.show()
# Test using mismatched arrays
with pytest.raises(ValueError):
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh, scalars='Spatial Cell Data', opacity='unc',)
p.show()
# Test with user defined transfer function
opacities = [0,0.2,0.9,0.2,0.1]
p = pyvista.Plotter(off_screen=OFF_SCREEN)
p.add_mesh(mesh, scalars='Spatial Point Data', opacity=opacities,)
p.show()
示例14: test_add_remove_floor
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def test_add_remove_floor():
pl = pyvista.Plotter()
pl.add_mesh(sphere)
pl.add_floor(color='b', line_width=2, lighting=True)
pl.add_bounding_box() # needed for update_bounds_axes
assert len(pl.renderer._floors) == 1
pl.add_mesh(sphere_b)
pl.update_bounds_axes()
assert len(pl.renderer._floors) == 1
pl.show()
pl = pyvista.Plotter()
pl.add_mesh(sphere)
pl.add_floor(color='b', line_width=2, lighting=True)
pl.remove_floors()
assert not pl.renderer._floors
pl.show()
示例15: update_coordinates
# 需要导入模块: import pyvista [as 别名]
# 或者: from pyvista import Plotter [as 别名]
def update_coordinates(self, points, mesh=None, render=True):
"""Update the points of an object in the plotter.
Parameters
----------
points : np.ndarray
Points to replace existing points.
mesh : vtk.PolyData or vtk.UnstructuredGrid, optional
Object that has already been added to the Plotter. If
None, uses last added mesh.
render : bool, optional
Forces an update to the render window. Default True.
"""
if mesh is None:
mesh = self.mesh
mesh.points = points
if render:
self.render()