You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/notebooks/plot.ipynb
+52-22Lines changed: 52 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -15,25 +15,19 @@
15
15
},
16
16
"outputs": [],
17
17
"source": [
18
-
"!pip install -q sme_contrib\n",
19
-
"import sme\n",
20
-
"import sme_contrib.plot as smeplot\n",
21
-
"from matplotlib import pyplot as plt\n",
18
+
"# !pip install -q sme_contrib\n",
22
19
"import pyvista as pv\n",
23
20
"from pyvista import examples\n",
21
+
"\n",
22
+
"pv.set_jupyter_backend(\"static\")\n",
23
+
"\n",
24
+
"import sme\n",
25
+
"import sme_contrib.plot as smeplot\n",
24
26
"import numpy as np\n",
25
27
"import tempfile\n",
26
28
"from IPython.display import HTML\n",
27
-
"from IPython.display import Video"
28
-
]
29
-
},
30
-
{
31
-
"cell_type": "code",
32
-
"execution_count": null,
33
-
"metadata": {},
34
-
"outputs": [],
35
-
"source": [
36
-
"pv.set_jupyter_backend(\"static\")"
29
+
"from IPython.display import Video\n",
30
+
"from matplotlib import pyplot as plt"
37
31
]
38
32
},
39
33
{
@@ -217,6 +211,15 @@
217
211
"- `concentrations3D` and `concentrationsAnimate3D`: These high-level API directly uses `sme.SimulationResult` objects as data input, but only plots concentrations by default. These are wrappers around the low-level functions that provide default plotting functions for each pane and handle the data preparation for each pane automatically."
218
212
]
219
213
},
214
+
{
215
+
"cell_type": "markdown",
216
+
"metadata": {},
217
+
"source": [
218
+
"**README:** Using `import pyvista as pv` in both a notebook and a module imported in the notebook will cause a premature initialization of `pyvista` when the imported module is initialized and in turn a configuration conflict that will prevent the notebook from working properly. You thus have to make sure that the `pyvista` module is only imported in one of the two. Since notebooks often have specific requirements for how the plots can be shown (statically or interactively) it is best to only import the needed objects from pyvista when developing a module and only importing the package-level module (`import pyvista...`) within notebooks that use this module. \n",
219
+
"\n",
220
+
"If a complete import of pyvista in a module is unavoidable, make sure to only import the called functions in the notebook and not the entire module, to prevent pyvista's `__init__` from running prematurely."
This follows the seaborn.FacetGrid concept. This function creates a grid of subplots where each subplot is filled by a function in the plotfuncs argument. The keys for plotfuncs and data must be the same, such that plotfuncs can be unambiguously mapped over the data dictionary. Do not attempt to plot 2D images and 3D images into the same facet grid, as this will create odd artifacts and may not work as expected.
148
147
149
148
Args:
150
149
data : (dict[str, np.ndarray]) A dictionary where keys are labels and values are numpy arrays containing the data to be plotted.
151
-
plotfuncs : (dict[str, Callable]) A dictionary where keys are labels and values are functions with signature ``f(label:str, data:np.ndarray | pyvista.ImageData | pyvista.UniformGrid, plotter:pv.Plotter, panel:tuple[int, int], show_cmap:bool=show_cmap, cmap=cmap, **plotfuncs_kwargs )`` -> None
150
+
plotfuncs : (dict[str, Callable]) A dictionary where keys are labels and values are functions with signature ``f(label:str, data:np.ndarray | pyvista.ImageData | pyvista.UniformGrid, plotter:Plotter, panel:tuple[int, int], show_cmap:bool=show_cmap, cmap=cmap, **plotfuncs_kwargs )`` -> None
152
151
show_cmap : bool, optional Whether to show the color map. Default is False.
153
-
cmap : (str | np.ndarray | pv.LookupTable), optional The color map to use. Default is "viridis".
152
+
cmap : (str | np.ndarray | LookupTable), optional The color map to use. Default is "viridis".
154
153
portrait : (bool), optional Whether to use a portrait layout. Default is False.
155
154
linked_views : (bool), optional Whether to link the views of the subplots. Default is True.
156
155
plotter_kwargs : (dict, optional) Additional keyword arguments to pass to the PyVista Plotter.
157
156
plotfuncs_kwargs : (dict[str, dict[str, Any]]), optional Additional keyword arguments to pass to each plotting function.
158
157
159
158
Returns:
160
-
pv.Plotter The PyVista Plotter object with the created facet plot.
159
+
Plotter The PyVista Plotter object with the created facet plot.
simulation_results (sme.SimulationResultList): a list of `SimulationResult` objects, i.e., a list of recorded frames of the simulations
387
386
species (list[str]): list of species to plot
388
387
show_cmap (bool, optional): Whether to show the colorbar on theplots or not. Defaults to False.
389
-
cmap (Union[str, np.ndarray, pv.LookupTable], optional): name of matplotlib colormap or custom colormap that maps scalar values to rbp. Defaults to "viridis".
388
+
cmap (Union[str, np.ndarray, LookupTable], optional): name of matplotlib colormap or custom colormap that maps scalar values to rbp. Defaults to "viridis".
390
389
portrait (bool, optional): Whether to use the smaller or larger number of plots as rows. Defaults to False.
391
390
titles (Union[list[dict[str, str]], None], optional): Titles of the different plots if not just the species name is desired. Defaults to None.
392
391
linked_views (bool, optional): link the view cameras. Defaults to True.
0 commit comments