Skip to content

Saving mesh_plot to image? #9

Answered by bwoodsend
3deo-chris asked this question in Q&A
Discussion options

You must be logged in to vote

For setting camera angles use view(). There's nothing special dedicated to isometric views but it's only a two-liner anyway:

vpl.view(camera_direction=[1, 1, 1])
vpl.reset_camera()

As for generating images, you save figures using save_fig().

Glueing those two together, your code should look something like:

import vtkplotlib as vpl

# Plot the rabbit. Replace this with your own mesh.
vpl.mesh_plot(vpl.data.get_rabbit_stl())

# Set the camera angle. Toggle the minus signs to switch views.
vpl.view(camera_direction=[-1, 1, 1])
# Let VTK choose a sensible zoom.
vpl.reset_camera()

# Take an snapshot and save it.
vpl.save_fig("image.jpg", pixels=(600, 600), off_screen=True)

# Add as many view…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 3deo-chris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #8 on June 28, 2021 21:09.