Skip to content

Commit

Permalink
Add interactive plots in documentation (#4938)
Browse files Browse the repository at this point in the history
* DynamicScraper: Add support for .png and .gif files

Query the plotter and use gif files if they are requested.
Use interactive (i.e.) vtksz files only if a scene exists in the plotter
fallback to static png if it does not.

* plot_directive: Add support for interactive scenes vis vrksz files

* plot_directive: Add option 'force_static'

Give the option to force a static image even if an interactive scene exists.
This allows to skip cases where the interactive scene is buggy or not as
expected.

* Replace "pyvista" scraper with DynamicScraper

* Use plot-directive instead of jupyter-execute in user-guide/*.rst

* plot-directive instead of jupyter-execute in sources/index.rst

* Apply suggestions from code review

* ViewerDirective: Support figure paths in either source or build directory.

The gallery extension generates the vtksz files under the source while the rest
of the documentation under build.  The ViewerDirective path replacements are
able to handle both now.

* sphinx_gallery: Add support for forcing static images

The sphinx gallery will look for the boolean variable
`PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT` in the parsed code to figure out if
static images should be generated instead of an interactive vtksz file.

Generation of static images can be also controlled at a block-level  defining
"PYVISTA_GALLERY_FORCE_STATIC = True" or "PYVISTA_GALLERY_FORCE_STATIC = False"
within the block.

* docs: use static images in examples that interactive does not look right

* docs: flying edges examples remove specular

It does not work well with interactive scenes and since flying edges is all
about creating a mesh it makes sense to sacrifice specular int his case.

* docs: plot-directive instead of jupyter-execute in getting-started/why

* Update tinypages test for offlineviewer

* docs: viewer_directive do path operation only on directories

strip filename using ".parent" to make sure we are operating on paths.
use "resolve()" to make comparing paths easier

* test_tinypages: Allow for both interactive scenes and static images

* test_tinypages: use static images for captions

the offlineviewer does not support captions yet.

* viewer_directive: offer alternative for is_relative for python < 3.9

`pathlib.Path.is_relative_to` was introduced in 3.9 while pyvista supports 3.8+.

* Update sphinx_gallery.py

* Update sphinx_gallery.py

* Apply suggestions from code review

* Update pyvista/ext/viewer_directive.py

* docs: add serve-html target

Add a target to allow serving the documentation via a http server.
This is required when generating interactive vtksz scenes.

* Update CONTRIBUTING.rst

* Update CONTRIBUTING.rst

* Update pyvista/ext/viewer_directive.py

* Update extrude-trim.py

* Update distance-between-surfaces.py

* Update sphinx_gallery.py

* Update preview-docs.yml

* Update preview-docs.yml

* Update docs.yml

* Update preview-docs.yml

* Delete .github/workflows/preview-docs.yml

* Update docs.yml

* sphinx-gallery: offer static and interactive scene as tabs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docs: serve-html target use any available port

By default `python -m http.server` uses port 8000. This allows to pick some available port.

Co-authored-by: Bane Sullivan <banesullivan@gmail.com>

* docs: user-guide/index remove PBR

PBR is not yet supported by vtk.js

* tests: simplify working in tinypages test

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* docs: update trimesh.org domain

Fixes intersphinx error: XXX

* tinypages: Add support for tabs

* docs: plot_directive will now produce tabbed documentation

* plot_directive: Add support for docsets

Using pyvista-plot:: in docset causes the snippet to appear twice during
parsing. Once including the `pyvista-plot` command and arguments as part of the
code  and once without.  We only process the second since this is when the
directive options are properly read.

* docs: make all docsets in charts.py static

* create-point-could example use static for first case

eye_dome_lighting is not implemented in vtk-js.

* [create-pull-request] update local intersphinx (#5161)

Co-authored-by: MatthewFlamm <MatthewFlamm@users.noreply.github.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* [pre-commit.ci] pre-commit autoupdate (#5180)

updates:
- [github.com/psf/black: 23.9.1 → 23.10.1](psf/black@23.9.1...23.10.1)
- [github.com/keewis/blackdoc: v0.3.8 → v0.3.9](keewis/blackdoc@v0.3.8...v0.3.9)
- [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.6.1](pre-commit/mirrors-mypy@v1.5.1...v1.6.1)
- [github.com/asottile/pyupgrade: v3.14.0 → v3.15.0](asottile/pyupgrade@v3.14.0...v3.15.0)
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/python-jsonschema/check-jsonschema: 0.27.0 → 0.27.1](python-jsonschema/check-jsonschema@0.27.0...0.27.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix rotation bug with 90 degrees (#5181)

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* remove deprecated multi_samples kwarg (#5185)

* Support button release events on interactor (#5160)

* Support button release events on interactor

* Fix AffineWidget usage

---------

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* fix trimesh intersphinx (#5187)

* Enchance BUILDING_GALLERY flag code (#5189)

* Changed the way BUILDING_GALLERY flag was defined to a better way

* Support python 3.12 and vtk 9.3.0 in CI (#5196)

* support python 3.12 and vtk 9.3.0 in CI

* fix mpl version constraint

* test 3.12 on windows

* Update .github/workflows/testing-and-deployment.yml

* fix typo

* use rc aiohttp for now

* fix vtk change for Tetrahedra in docstring

* comment for aiohttp pin

* use in vtk master testing

* add to classifiers

* Apply suggestions from code review

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

---------

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Add option to get `figure_path` from environment variables (#5194)

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Remove `cell_arrays` in documentation (#5199)

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Add option to always get screenshots from plotter shows (#5197)

* feat: Add option to always get screenshots from plotter shows

* Add test

* Update pyvista/plotting/plotter.py

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Substitute all SCREENSHOT_ONLY appearences

* Update test_plotter.py

* Update test_plotter.py

* Use tmpdir

* Add global variable reset fixture

---------

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Add conversion of 3D label maps to labeled meshes with SurfaceNets. (#5176)

* Add conversion of 3D label maps to labeled meshes.

ImageData.contour_labeled is added and SurfaceNets3D algorithm from
a pre-release version of VTK is used. This is particularly useful for
visualization of medical images with their labels and the outputs of
multi-label segmentation maps.

Implements #5170

Note, version of vtk 9.3+ must be used which is currently in the pre-release
stage. Otherwise, the example is not generated and the test is not run.

See also:
Sarah F. Frisken, SurfaceNets for Multi-Label Segmentations with Preservation
of Sharp Boundaries, Journal of Computer Graphics Techniques (JCGT), vol. 11,
no. 1, 34-54, 2022. Available online http://jcgt.org/published/0011/01/03/

Note, silencing Mypy errors (as in #3837):
pyvista/core/filters/image_data.py:853: error: Argument 1 to "set_default_active_scalars" has incompatible type "ImageDataFilters"; expected "DataSet"  [arg-type]
pyvista/core/filters/image_data.py:854: error: "ImageDataFilters" has no attribute "active_scalars_info"  [attr-defined]
pyvista/core/filters/image_data.py:858: error: "ImageDataFilters" has no attribute "get_array_association"  [attr-defined]

* Refer to the contouring example

* Add tests for SurfaceNets contour extraction

* Update comments

* Update pyvista/core/filters/image_data.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Update pyvista/core/filters/image_data.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Update examples/01-filter/contouring.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Update pyvista/core/filters/image_data.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Use FieldAssiciation enums

* Use FieldAssociation enums correctly

* Add tests for improved coverage

* Add tests for improved coverage

* Fix quotes in tests

---------

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
Co-authored-by: Bane Sullivan <banesullivan@gmail.com>

* Add more typehints (#5171)

* add typehints

* use forward declaration

* moar types

* Update pyvista/core/utilities/helpers.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Apply suggestions from code review

* Apply suggestions from code review

* pin numpy>=1.21.0

* Wide types

* final touch on pointset

---------

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Use python 3.12 and vtk 9.3.0 in Build Documentation (#5202)

* Use python 3.12 and vtk 9.3.0 in Build Documentation

* Apply suggestions from code review

* Bump jupyterlab from 4.0.7 to 4.0.9 (#5219)

Bumps [jupyterlab](https://github.com/jupyterlab/jupyterlab) from 4.0.7 to 4.0.9.
- [Release notes](https://github.com/jupyterlab/jupyterlab/releases)
- [Changelog](https://github.com/jupyterlab/jupyterlab/blob/@jupyterlab/lsp@4.0.9/CHANGELOG.md)
- [Commits](https://github.com/jupyterlab/jupyterlab/compare/@jupyterlab/lsp@4.0.7...@jupyterlab/lsp@4.0.9)

---
updated-dependencies:
- dependency-name: jupyterlab
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump trimesh from 3.23.5 to 4.0.5 (#5222)

Bumps [trimesh](https://github.com/mikedh/trimesh) from 3.23.5 to 4.0.5.
- [Release notes](https://github.com/mikedh/trimesh/releases)
- [Commits](mikedh/trimesh@3.23.5...4.0.5)

---
updated-dependencies:
- dependency-name: trimesh
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump trame from 3.2.8 to 3.3.0 (#5223)

Bumps [trame](https://github.com/Kitware/trame) from 3.2.8 to 3.3.0.
- [Release notes](https://github.com/Kitware/trame/releases)
- [Changelog](https://github.com/Kitware/trame/blob/master/CHANGELOG.md)
- [Commits](Kitware/trame@v3.2.8...v3.3.0)

---
updated-dependencies:
- dependency-name: trame
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump osmnx from 1.7.0 to 1.7.1 (#5220)

Bumps [osmnx](https://github.com/gboeing/osmnx) from 1.7.0 to 1.7.1.
- [Changelog](https://github.com/gboeing/osmnx/blob/main/CHANGELOG.md)
- [Commits](gboeing/osmnx@v1.7.0...v1.7.1)

---
updated-dependencies:
- dependency-name: osmnx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump scipy from 1.11.3 to 1.11.4 (#5221)

Bumps [scipy](https://github.com/scipy/scipy) from 1.11.3 to 1.11.4.
- [Release notes](https://github.com/scipy/scipy/releases)
- [Commits](scipy/scipy@v1.11.3...v1.11.4)

---
updated-dependencies:
- dependency-name: scipy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add `input_validation` package (#5100)

* Add input_validation package

* Update typing

* Update check_is_instance

* Revert updates to pyvista_ndarray.py

* Remove 'not not' repetition

* Update test_check_is_type

* Update test_check_is_subdtype

* Pre-commit

* Remove use of check_is_ArrayLike

* Update test_check_is_type

* Update test_check_is_type

* Update cast_array_to_NDArray

* Update cast_array_to_NDArray

* Remove np.zeros validation from coerce_shapelike_as_shape

* Update cast_array_to_NDArray

* Update docstrings

* Add check_is_iterable

* Add positional, kwarg special parameters

* Update docstrings, remove NumPy typing, rename functions

* Refactor coerce_arrayNx3 into validate_arrayNx3

* Split into separate modules

* Update module docstrings

* Move array casting to utilities

* Remove redundant calls to check_is_string

* Update test_utilities.py

* Pre-commit

* Rename validate_numeric_array -> validate_array

* Pre-commit

* Add validate_arrayN and check_length

* Pre-commit

* Add check length params to validate_array

* Improve test coverage

* Update tests

* Add check_is_sequence_of_strings

* Add check_string_is_in_list

* Add length, broadcast, and reshape options; add validate_array3

* Update typing

* Update typing

* Add must_be_nonnegative constraint; validate_uintlike_array

* Rename constraint params with 'must_be' prefix

* Update test_validate_uintlike_arrayN

* Remove redundant function

* Update test coverage

* Update docs

* Update docs; add check_is_scalar; minor code changes

* Improve test coverage

* Update docs, add examples

* Update pyvista/core/input_validation/validate.py

* Add API TOC autosummary

* Rename check_length -> check_has_length

* Change 'check that' to 'check if' in docs

* Rename check_string_is_in_iterable -> check_is_string_in_iterable

* Rename validate_transform_as_array3x3 -> validate_transform3x3

* Rename validate_transform_as_array4x4 -> validate_transform4x4

* Rename validate_uintlike_arrayN -> validate_arrayN_uintlike

* Update function special args to be consisent

* Rename transform input arg: transformlike -> transform

* Update module headers

* Update validation.rst

* Update CONTRIBUTING.rst

* Update docstrings

* Update validation.rst

* Update docstrings to fix build failure

* Add short-circuit return to avoid call to np.asanyarry

* Avoid redundant dtype check

* Rework _validate_shape_value to improve performance

* Update docstrings to fix build failure

* Fix typo

* Rework check_has_shape to improve performance

* Rework dtype checks to improve performance

* Optimization: replace calls to cast_to_ndarray with isinstance checks

* Add early retun for common cases in check_is_real

* Update validate.py

* Update CONTRIBUTING.rst

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Update tests/core/test_input_validation.py

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Update tests, improve coverage

* Update CONTRIBUTING.rst

* Update validate.py

* Update docs

* Update docs

* Update docs

* Update docs, add 'See Also'

* Update docs and typing

* Pre-commit

* Update docs, typing, add cross-references

* Update docs, add examples, minor fixes/edits

* Rename reshape -> reshape_to

* Add strict and axis params to check_is_sorted

* Update docstring

* Improve test coverage

* Simplify error re-raises

* Add validate_axes

* Update docstring

* Update tests

* Apply suggestions from code review

* Add name param to validate_axes

---------

Co-authored-by: Erik Bedard <bedarder@gmail.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Fix small typo (#5225)

* Add Text3DSource class (#5218)

* Add Text3DSource class

* Update docstring

* Update depth arg position

* Update tests

* Update geometric_sources.py

* Refactor tests

* Update tests

* Update tests

* Update tests

* Apply suggestions from code review

---------

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* Add `edge_opacity` property to `Property` class (#5192)

* Add `edge_opacity` property to `Property` class

* Update _property.py

* Update _property.py

* Update test_property.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update _property.py

* Update pyvista/plotting/_property.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Update test_property.py

* Update pyvista/plotting/_property.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Update pyvista/plotting/_property.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `edges_opacity` property to `Theme` class

* Apply suggestions from code review

* Update themes.py

* Apply suggestions from code review

* Update _property.py

* Update _property.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `edge_opacity` as a keyword arg to `add_mesh`

* Apply suggestions from code review

* Update _property.py

* Update _property.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update _property.py

* Update _property.py

* Apply suggestions from code review

* Update pyvista/plotting/_property.py

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* Fix numpydoc-validation error

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Add embeddable jupyter widget (#5168)

* Add embeddable jupyter widget

* Fix debugging

* Add basic test

* Add test-case in tinypages test for new widget (#5206)

Co-authored-by: Christos Tsolakis <christos.tsolakis@kitware.com>

* Add jupyter_sphinx to test dependencies

* Remove the tinypages test

* Remove jupyter_sphinx extension from test

---------

Co-authored-by: Christos Tsolakis <christos.tsolakis@kitware.com>

* Add `pack_labels` and `sort_labels` filters (#4802)

* Add pack_labels and sort_labels filters

* Fix failed doctest, remove unused test

* Add checks for VTK>=9.3

* Add doctest skips

* Generalize pack_labels to work with VTK < 9.3

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_dataset_filters.py

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Update data_set.py

* Update data_set.py

* Update data_set.py

* Update data_set.py

* Update docs and vtk checks

* Update filter to limit copying

* Update docstring

---------

Co-authored-by: Erik Bedard <bedarder@gmail.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Add local suppression of VTK debug messages (#5228)

Co-authored-by: Bane Sullivan <banesullivan@gmail.com>

* Deprecate/fix `PolyData.n_faces` (#5229)

* deprecate n_faces

* indent deprecation comment

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* move module globals to class variables

* Remove the PolyData.n_faces example

Deprecation warning was causing failure during doctest

* fix n_faces_strict doc example

---------

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* plot_directive: allow captions when tabs are used

* charts: doc_subs indent replacements to accommodate pyvista-plot directive

* tinypages: Add sphinx-design plugin to give access to tabs

* Update pointset.py

* Update requirements_test.txt

* docs: force interactive plot in create-pixel-art example

* Add documentation about PYVISTA_GALLERY_FORCE_STATIC* flags

* docs: fix spacing in PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT documentation

* docs: Various spelling and style fixes

Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>

* docs: set port of make serve to something predictable

Co-authored-by: Bane Sullivan <banesullivan@gmail.com>

* tests: make package requirements for tests less strict

Follows the current convention where:

- requirements_docs.txt: pin everything because our documentation build tends to be fragile and is only fully executed around releases
- requirements_test.txt: limit dependencies by minor release and let dependabot bump these which we can easily pick up on errors, deprecation warnings, or breakages
- requirements.txt: same as requirements_test.txt but this is just the core dependencies

Co-authored-by: Bane Sullivan <banesullivan@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>
Co-authored-by: Christos Tsolakis <ChristosT@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bane Sullivan <banesullivan@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: MatthewFlamm <MatthewFlamm@users.noreply.github.com>
Co-authored-by: Kevin Marchais <kevinmarchais@gmail.com>
Co-authored-by: Alex Kaszynski <akascap@gmail.com>
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
Co-authored-by: Amirhossein Safarzadeh <includesafarof@gmail.com>
Co-authored-by: Alex Fernandez <21alex295@gmail.com>
Co-authored-by: Jan Margeta <jmargeta@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: user27182 <89109579+user27182@users.noreply.github.com>
Co-authored-by: Erik Bedard <bedarder@gmail.com>
Co-authored-by: darikg <darikg@users.noreply.github.com>
  • Loading branch information
17 people authored Dec 14, 2023
1 parent 30221ea commit b960c22
Show file tree
Hide file tree
Showing 83 changed files with 1,855 additions and 895 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ The first time you build the documentation locally will take a while as all the
examples need to be built. After the first build, the documentation should take
a fraction of the time.

To test this locally you need to run a http server in the html directory with:

.. code:: bash
make serve-html
Clearing the Local Build
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 5 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ linkcheck:

linkcheck-grep:
@! grep -h "^.*:.*: \[\(\(local\)\|\(broken\)\)\]" _build/linkcheck/output.txt

# Spin up a local http server to view the rendered documentation.
# This is required for interactive examples to work.
serve-html:
python -m http.server 11000 --directory "$(BUILDDIR)"/html
4 changes: 3 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pyvista
from pyvista.core.errors import PyVistaDeprecationWarning
from pyvista.core.utilities.docs import linkcode_resolve, pv_html_page_context # noqa: F401
from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper

# Manage errors
pyvista.set_error_output_file("errors.txt")
Expand Down Expand Up @@ -73,6 +74,7 @@
"numpydoc",
"pyvista.ext.coverage",
"pyvista.ext.plot_directive",
"pyvista.ext.viewer_directive",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.linkcode", # This adds the button ``[Source]`` to each Python API site by calling ``linkcode_resolve``
Expand Down Expand Up @@ -358,7 +360,7 @@ def __repr__(self):
"backreferences_dir": None,
# Modules for which function level galleries are created. In
"doc_module": "pyvista",
"image_scrapers": ("pyvista", "matplotlib"),
"image_scrapers": (DynamicScraper(), "matplotlib"),
"first_notebook_cell": "%matplotlib inline",
"reset_modules": (reset_pyvista,),
"reset_modules_order": "both",
Expand Down
10 changes: 7 additions & 3 deletions doc/source/getting-started/why.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ object in VTK cannot. It then makes sense that a
:func:`pyvista.PolyDataFilters.subdivide` method be added to the existing
triangular surface mesh. That way, subdivision can be performed with:

.. jupyter-execute::
.. pyvista-plot::
:context:

import pyvista
mesh = pyvista.Plane().triangulate()
Expand All @@ -120,7 +121,9 @@ meshes. This data can be easily accessed from the dataset attributes
like :attr:`pyvista.DataSet.points`. For example the first 10 points
of a circle from pyvista can be accessed with:

.. jupyter-execute::
.. pyvista-plot::
:context:
:nofigs:

circle = pyvista.Circle()
circle.points[:10]
Expand All @@ -132,7 +135,8 @@ At the same time, a variety of PyVista objects can be generated
directly from numpy arrays. For example, below we generate a vector
field of arrows using :func:`numpy.meshgrid`:

.. jupyter-execute::
.. pyvista-plot::
:context:

import pyvista
import numpy as np
Expand Down
27 changes: 19 additions & 8 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ Here are some brief interactive examples that demonstrate how you
might want to use PyVista:


.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:context:
:include-source: false
:force_static:

import pyvista
pyvista.set_jupyter_backend('static')
Expand All @@ -88,7 +90,8 @@ Maps and Geoscience
~~~~~~~~~~~~~~~~~~~
Download the surface elevation map of Mount St. Helens and plot it.

.. jupyter-execute::
.. pyvista-plot::
:context:

from pyvista import examples
mesh = examples.download_st_helens()
Expand All @@ -102,7 +105,9 @@ Finite Element Analysis
~~~~~~~~~~~~~~~~~~~~~~~
Plot the 'X' component of elastic stress of a 3D notch specimen.

.. jupyter-execute::

.. pyvista-plot::
:context:

from pyvista import examples
mesh = examples.download_notch_stress()
Expand All @@ -115,7 +120,9 @@ Easily integrate with NumPy and create a variety of geometries and plot
them. You could use any geometry to create your glyphs, or even plot
the points directly.

.. jupyter-execute::

.. pyvista-plot::
:context:

import numpy as np
import pyvista
Expand All @@ -134,7 +141,8 @@ Plot a Spline
~~~~~~~~~~~~~
Generate a spline from an array of NumPy points.

.. jupyter-execute::
.. pyvista-plot::
:context:

import numpy as np
import pyvista
Expand All @@ -155,7 +163,8 @@ Boolean Operations on Meshes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Subtract a sphere from a cube mesh.

.. jupyter-execute::
.. pyvista-plot::
:context:

import pyvista
import numpy as np
Expand Down Expand Up @@ -183,7 +192,9 @@ Plot the :math:`3d_{xy}` orbital of a hydrogen atom.
.. note::
This example requires `sympy <https://www.sympy.org/>`_.

.. jupyter-execute::
.. pyvista-plot::
:context:
:force_static:

from pyvista import examples
grid = examples.load_hydrogen_orbital(3, 2, -2)
Expand Down
16 changes: 12 additions & 4 deletions doc/source/user-guide/data_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ field arrays.
Geometry in PyVista is represented as points and cells. For example,
consider a single cell within a |PolyData|:

.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:context:
:include-source: false
:force_static:

import pyvista
pyvista.set_plot_theme('document')
Expand All @@ -81,8 +83,10 @@ we've done above (lists of arrays with indices). VTK (and hence
PyVista) have multiple classes that represent different data
shapes. The most important dataset classes are shown below:

.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:context:
:include-source: false


from pyvista import demos
demos.plot_datasets()
Expand Down Expand Up @@ -316,6 +320,7 @@ While we're at it, let's annotate this plot to describe this mesh.

.. pyvista-plot::
:context:
:force_static:

>>> pl = pyvista.Plotter()
>>> pl.add_mesh(mesh, show_edges=True, line_width=5)
Expand Down Expand Up @@ -410,6 +415,7 @@ Let's also plot this basic mesh:

.. pyvista-plot::
:context:
:force_static:

>>> pl = pyvista.Plotter()
>>> pl.add_mesh(ugrid, show_edges=True, line_width=5)
Expand Down Expand Up @@ -486,6 +492,7 @@ assigned.

.. pyvista-plot::
:context:
:force_static:

>>> pl = pyvista.Plotter()
>>> pl.add_mesh(ugrid, show_edges=True, line_width=5)
Expand Down Expand Up @@ -561,6 +568,7 @@ lowest value at ``Point 0`` to the highest value at ``Point 8``.

.. pyvista-plot::
:context:
:force_static:

>>> pl = pyvista.Plotter()
>>> pl.add_mesh(ugrid, show_edges=True, line_width=5)
Expand Down
12 changes: 7 additions & 5 deletions doc/source/user-guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ This basic example demonstrates three key features of PyVista:
.. _numpy: https://numpy.org/
.. _matplotlib: https://matplotlib.org/

.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:include-source: false
:nofigs:
:context:

import pyvista
pyvista.set_jupyter_backend('static')
Expand All @@ -35,13 +37,13 @@ Here, we download the `Stanford dragon mesh
to height, and plot it using a web-viewer. This same example will run
identically locally.

.. jupyter-execute::
.. pyvista-plot::
:context:

>>> from pyvista import examples
>>> mesh = examples.download_dragon()
>>> mesh['scalars'] = mesh.points[:, 1]
>>> mesh.plot(cpos='xy', cmap='plasma', pbr=True, metallic=1.0, roughness=0.6,
... zoom=1.7)
>>> mesh.plot(cpos='xy', cmap='plasma')

.. note::
This example (and many others) is interactive.
Expand Down
12 changes: 8 additions & 4 deletions doc/source/user-guide/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ arguments.
To get started, try out the :func:`pyvista.plot` convenience method
that is bound to each PyVista data object.

.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:include-source: false
:nofigs:
:context:

# must have this here as our global backend may not be static
import pyvista
Expand All @@ -155,7 +157,8 @@ that is bound to each PyVista data object.
pyvista.global_theme.show_scalar_bar = False


.. jupyter-execute::
.. pyvista-plot::
:context:

import pyvista as pv
from pyvista import examples
Expand All @@ -170,7 +173,8 @@ instantiate a plotter such as :class:`pyvista.Plotter` or
will create a rendering window that will pause the execution of the
code after calling :func:`show() <pyvista.Plotter.show>`.

.. jupyter-execute::
.. pyvista-plot::
:context:

mesh = examples.load_airplane()

Expand Down
22 changes: 13 additions & 9 deletions doc/source/user-guide/vtk_to_pyvista.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ However, with PyVista you only need:
grid.plot(cpos='xy', show_scalar_bar=False, cmap='coolwarm')
..
This is here so we can generate a plot. We have to repeat
everything since jupyter-execute doesn't allow for
plain text between command blocks.
This is here so we can generate a plot. We used to have to repeat
everything since jupyter-execute didn't allow for
plain text between command blocks. We have to try again with pyvista-plot.
.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:include-source: false
:context:

import pyvista as pv
pv.set_plot_theme('document')
Expand Down Expand Up @@ -274,8 +275,10 @@ In the :class:`collision <pyvista.PolyDataFilters.collision>` filter,
we demonstrate how to calculate the collision between two meshes. For
example:

.. jupyter-execute::
:hide-code:
.. pyvista-plot::
:context:
:nofigs:
:include-source: false

# must have this here as our global backend may not be static
import pyvista
Expand All @@ -284,7 +287,8 @@ example:
pyvista.global_theme.anti_aliasing = 'fxaa'


.. jupyter-execute::
.. pyvista-plot::
:context:

import pyvista

Expand Down Expand Up @@ -312,7 +316,7 @@ you may want to use VTK classes directly.
Note that nothing stops you from using VTK classes and then wrapping
the output with PyVista. For example:

.. jupyter-execute::
.. pyvista-plot::

import vtk
import pyvista
Expand Down
Loading

0 comments on commit b960c22

Please sign in to comment.