<jupyter_start><jupyter_text>Load and Plot from a File {read_file_example}=========================Read a dataset from a known file type. Loading a mesh is trivial - if your data is in one of the many supportedfile formats, simply use `pyvista.read`{.interpreted-text role="func"}to load your spatially referenced dataset into a PyVista mesh object.The following code block uses a built-in example file and displays anairplane mesh.<jupyter_code># sphinx_gallery_thumbnail_number = 5
import pyvista as pv
from pyvista import examples<jupyter_output><empty_output><jupyter_text>The following code block uses a built-in example file, displays anairplane mesh and returns the camera\'s position:<jupyter_code># Get a sample file
filename = examples.planefile
filename<jupyter_output><empty_output><jupyter_text>Note the above filename, it\'s a `.ply` file - one of the many supportedformats in PyVista.<jupyter_code>mesh = pv.read(filename)
cpos = mesh.plot()<jupyter_output><empty_output><jupyter_text>You can also take a screenshot without creating an interactive plotwindow using the `Plotter`:<jupyter_code>plotter = pv.Plotter(off_screen=True)
plotter.add_mesh(mesh)
plotter.show(screenshot="myscreenshot.png")<jupyter_output><empty_output><jupyter_text>The points from the mesh are directly accessible as a NumPy array:<jupyter_code>mesh.points<jupyter_output><empty_output><jupyter_text>The faces from the mesh are also directly accessible as a NumPy array:<jupyter_code>mesh.faces.reshape(-1, 4)[:, 1:] # triangular faces<jupyter_output><empty_output><jupyter_text>Loading other files types is just as easy! Simply pass your file path tothe `pyvista.read`{.interpreted-text role="func"} function and that\'sit!Here are a few other examples - simply replace `examples.download_*` inthe examples below with `pyvista.read('path/to/you/file.ext')` Example STL file:<jupyter_code>mesh = examples.download_cad_model()
cpos = [(107.0, 68.5, 204.0), (128.0, 86.5, 223.5), (0.45, 0.36, -0.8)]
mesh.plot(cpos=cpos)<jupyter_output><empty_output><jupyter_text>Example OBJ file<jupyter_code>mesh = examples.download_doorman()
mesh.plot(cpos="xy")<jupyter_output><empty_output><jupyter_text>Example BYU file<jupyter_code>mesh = examples.download_teapot()
mesh.plot(cpos=[-1, 2, -5], show_edges=True)<jupyter_output><empty_output><jupyter_text>Example VTK file<jupyter_code>mesh = examples.download_bunny_coarse()
cpos = [(0.2, 0.3, 0.9), (0, 0, 0), (0, 1, 0)]
mesh.plot(cpos=cpos, show_edges=True, color=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12173913043478261, 'fraction_numerical': 0.019367588932806323, 'mean_word_length': 7.550675675675675, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '111484', 'license': 'MIT', 'n_tokens_mistral': 911, 'n_tokens_neox': 859, 'n_words': 222, 'path': 'locale/examples/00-load/read-file.ipynb', 'repo_name': 'tkoyama010/pyvista-doc-translations', 'size': '2530'}