geovista.themes#

Configures custom pyvista themes for geovista.

These themes are discoverable by pyvista and registered through [project.entry-points] TOML table metadata (PEP621) in our pyproject.toml.

Registered themes may be enabled through geovista.set_plot_theme(), pyvista.set_plot_theme() or the PYVISTA_PLOT_THEME environment variable.

See Also#

pyvista.registered_themes()

Enumeration of available registered themes.

ノート#

Added in version 0.6.0.

Classes#

GeoVistaDocumentTheme

Theme used for building the documentation.

GeoVistaTheme

Default geovista plot theme.

ThemeMixin

Common geovista plotting theme property state.

Functions#

resolve_theme_name(name)

Create an instance of the registered theme or dotted path theme class.

restore_plot_theme()

Activate the previous plot theme.

set_plot_theme(theme, /, *[, bootstrap])

Set plotting parameters to a predefined theme.

モジュール内容#

class geovista.themes.GeoVistaDocumentTheme[ソース]#

Bases: pyvista.plotting.themes.DocumentTheme, ThemeMixin

Theme used for building the documentation.

Examples#

Make the geovista_document theme the global default using an instance of the theme.

>>> import pyvista as pv
>>> from geovista.themes import GeoVistaDocumentTheme
>>> pv.set_plot_theme(GeoVistaDocumentTheme())

Alternatively, enable the theme via its string name.

>>> pv.set_plot_theme("geovista_document")

ノート#

Added in version 0.6.0.

Documentation plotting theme for geovista.

class geovista.themes.GeoVistaTheme[ソース]#

Bases: pyvista.plotting.themes.Theme, ThemeMixin

Default geovista plot theme.

Examples#

Make the geovista theme the global default using an instance of the theme.

>>> import pyvista as pv
>>> from geovista.themes import GeoVistaTheme
>>> pv.set_plot_theme(GeoVistaTheme())

Alternatively, enable the theme via its string name.

>>> pv.set_plot_theme("geovista")

ノート#

Added in version 0.6.0.

Default plotting theme for geovista.

class geovista.themes.ThemeMixin[ソース]#

Common geovista plotting theme property state.

ノート

Added in version 0.6.0.

mixin_state()[ソース]#

Configure common property state.

geovista.themes.resolve_theme_name(name)[ソース]#

Create an instance of the registered theme or dotted path theme class.

Parameters:
namestr

The name of the registered theme to lookup or the dotted path package.module:ClassName theme to be created.

Returns:
Theme | None

An instance of the theme or None if the requested theme is not registered.

Raises:
ValueError

When name is an invalid dotted path specification or cannot be imported.

ノート

Added in version 0.6.0.

geovista.themes.restore_plot_theme()[ソース]#

Activate the previous plot theme.

Provides a convenience to undo the last call to geovista.themes.set_plot_theme(). Note that the entire call stack history is cached, so multiple calls to geovista.themes.set_plot_theme() may be undone in reverse order to restore a previous theme.

When no cached theme is available, the current theme will remain active and None is returned.

Returns:
Theme | None

The previously cached theme if available, otherwise None.

ノート

Added in version 0.6.0.

geovista.themes.set_plot_theme(theme, /, *, bootstrap=False)[ソース]#

Set plotting parameters to a predefined theme.

The enabled plot theme will be used by all plotters and rendering.

Requests to enable a plot theme will be ignored when the environment variable GEOVISTA_DISABLE_PLOT_THEME is set.

Note that the replaced theme is cached and may be restored with geovista.themes.restore_plot_theme().

Parameters:
themeTheme or str

The theme to apply, which may be either:

bootstrapbool, default=False

When True, theme configuration is skipped if the environment variable PYVISTA_PLOT_THEME is set. Otherwise, the provided theme will be enabled regardless of that environment variable. This behaviour allows a pre-defined PYVISTA_PLOT_THEME to take precedence.

Returns:
bool

True if the theme was successfully enabled, otherwise False.

Raises:
ValueError

When theme is an invalid dotted path specification or cannot be imported.

参考

geovista.themes.restore_plot_theme()

Reinstates the plot theme to the previous replaced theme.

pyvista.registered_themes()

The list of available registered themes.

pyvista.plotting.themes.Theme

Base class for all themes. Subclasses with the class property _default_name are discoverable by pyvista.

ノート

Added in version 0.6.0.

Examples

Set the default geovista theme.

>>> import geovista as gv
>>> gv.set_plot_theme("geovista")
True

Set the pyvista dark theme.

>>> gv.set_plot_theme("dark")
True

Load a theme from an importable package module specified as a dotted path.

>>> gv.set_plot_theme("geovista.themes:GeoVistaTheme")
True

Set the pyvista paraview theme.

>>> from pyvista import themes
>>> gv.set_plot_theme(themes.ParaViewTheme())
True