ogstools.plot package#
Plotting utilities for simple access.
- ogstools.plot.animate(fig, plot_func, *args, **kwargs)[source]#
- Create an animation by applying a plot function on a sequence of meshes. - Parameters:
- fig (Figure) – The figure on which the animation is rendered 
- plot_func (Callable) – The function which is applied for all timevalues. Expects to read a time value and a mesh. 
 
- Return type:
- FuncAnimation 
 - Positional Arguments:
- Sequences where each element corresponds to a frame. plot_func has to accept the individual elements of these sequences as arguments. Most common choice here would be a MeshSeries as an iterator for the meshes and possibly its timevalues for labeling. 
- Keyword Arguments:
- interval: Delay between frames in milliseconds (default=50). 
- repeat: Whether the animation repeats at the end. 
 
 
- ogstools.plot.compute_levels(lower, upper, n_ticks)[source]#
- Return an array in the interval [lower, upper] with terminating decimals. - The length of the arrays will be close to n_ticks. At the boundaries the tickspacing may differ from the remaining array. - Return type:
- ndarray 
 
- ogstools.plot.contourf(meshes, variable, fig=None, ax=None, interactive=None, **kwargs)[source]#
- Plot the variable field of meshes with default settings. - The resulting figure adheres to the configurations in plot.setup. For 2D meshes matplotlib backend is used, for 3D pyvista backend. - Parameters:
- meshes (list[UnstructuredGrid] | ndarray | UnstructuredGrid) – Singular mesh of 2D numpy array of meshes 
- variable (Variable | str) – The field to be visualized on all meshes 
- fig (Figure | None) – matplotlib figure to use for plotting 
- ax (Axes | None) – matplotlib axis to use for plotting 
- interactive (bool | None) – By default: 2D mesh -> matplotlib, 3D mesh -> pyvista, if True: always use interactive pyvista plot if False and 3D mesh: -> pyvista static Image 
 
- Return type:
- Figure | Plotter | Image | list[Plotter] | list[Image] | None 
 - Keyword Arguments:
- cb_labelsize: colorbar labelsize 
- cb_loc: colorbar location (‘left’ or ‘right’) 
- cb_pad: colorbar padding 
- cmap: colormap 
- dpi: resolution 
- figsize: figure size 
- fontsize size for labels and captions 
- levels: user defined levels 
- log_scaled: logarithmic scaling 
- show_edges: show element edges 
- show_max: mark the location of the maximum value 
- show_min: mark the location of the minimum value 
- show_region_bounds: show the edges of the different regions 
- vmin: minimum value 
- vmax: maximum value 
 
 
- ogstools.plot.contourf_pv(mesh, variable, show_edges=True, opacities=None, lighting=False, categoric=None, **kwargs)[source]#
- General 3D plot using pyvista - Parameters:
- mesh (UnstructuredGrid) – The mesh to be plotted with pyvista. 
- variable (str | Variable) – The variable which should be shown. 
- show_edges (bool) – If True, draw edges as black lines 
- opacities (dict[int, float] | None) – Dictionary, mapping opacities to material ids. Default None (all opaque), Example: {1:0.0 # transparent, 2:1 # opaque, 3:0.5} All not provided ids are rendered as opaque. 
- lighting (bool) – If True, use lighting in the visualization. 
- categoric (bool | None) – If True, use a categoric colormap. By default it uses the variable to determine if this should be True. 
 
- Returns:
- A pyvista Plotter object. Use .show() to display the scene. 
- Return type:
- Plotter 
 
- ogstools.plot.heatmap(data, variable, fig=None, ax=None, x_vals=None, y_vals=None, **kwargs)[source]#
- Create a heatmap plot of given data. - Parameters:
- data (ndarray) – The two-dimensional data of interest. 
- variable (Variable) – Provides the label and colormap for the colorbar. 
- fig (Figure | None) – Optionally plot into this figure. 
- ax (Axes | None) – Optionally plot into this Axes. 
- x_vals (ndarray | None) – one-dimensional x_values of the data. 
- y_vals (ndarray | None) – one-dimensional y_values of the data. 
 
- Return type:
- Figure | None 
 - Keyword Arguments:
- figsize: figure size 
- dpi: resolution 
- vmin: minimum value of the colorbar 
- vmax: maximum value of the colorbar 
- num_levels: Number of levels (approximation) 
- log_scale: If True, use logarithmic sclaing 
- aspect: Aspect ratio of the plt.Axes (y/x) 
- fontsize: fontsize 
 
 - Returns:
- A figure with a heatmap 
- Return type:
- Figure | None 
 
- ogstools.plot.line(dataset, var1=None, var2=None, ax=None, sort=True, **kwargs)[source]#
- Plot some data of a (1D) mesh. - You can pass “x”, “y” or “z” to either of x_var or y_var to specify which spatial dimension should be used for the corresponding axis. You can also pass two data variables for a phase plot. if no value is given, automatic detection of spatial axis is tried. - >>> line(mesh) # z=const: y over x, y=const: z over x, x=const: z over y >>> line(mesh, ot.variables.temperature) # temperature over x, y or z >>> line(mesh, "y", "temperature") # temperature over y >>> line(mesh, ot.variables.pressure, "y") # y over pressure >>> line(mesh, "pressure", "temperature") # temperature over pressure - Parameters:
- dataset (DataSet | Sequence[DataSet]) – The mesh which contains the data to plot 
- var1 (str | Variable | None) – Variable for the x-axis if var2 is given else for y-axis. 
- var2 (str | Variable | None) – Variable for the y-axis if var1 is given. 
- ax (Axes | None) – The matplotlib axis to use for plotting, if None a new figure will be created. 
- sort (bool) – Automatically sort the values along the dimension of the mesh with the largest extent 
 
- Return type:
- Figure | None 
 - Keyword Arguments:
- figsize: figure size (default=[16, 10]) 
- color: color of the line 
- linewidth: width of the line 
- linestyle: style of the line 
- label: label in the legend 
- grid: if True, show grid 
- monospace: if True, the legend uses a monospace font 
- loc: location of the legend (default=”upper right”) 
- annotate: string to be annotate at the center of the mesh 
- all other kwargs get passed to matplotlib’s plot function 
 
- Note:
- Using loc=”best” will take a long time, if you plot lines on top of a contourplot, as matplotlib is calculating the best position against all the underlying cells. 
 
- ogstools.plot.quiver(mesh, ax, variable, projection=None, glyph_type='arrow')[source]#
- Plot arrows or lines corresponding to vectors on a matplotlib axis. - Parameters:
- mesh (DataSet) – Mesh containing the vector variable 
- ax (Axes) – Matplotlib axis to plot onto 
- variable (Vector) – Vector variable to visualize 
- projection (int | None) – Index of flat dimension (e.g. 2 for z axis), gets automatically determined if not given 
- glyph_type (Literal['arrow', 'line']) – Whether to plot arrows or lines. 
 
 
- ogstools.plot.streamlines(mesh, ax, variable, projection=None)[source]#
- Plot the vector streamlines on a matplotlib axis. - Parameters:
- mesh (DataSet) – Mesh containing the vector variable 
- ax (Axes) – Matplotlib axis to plot onto 
- variable (Vector) – Vector variable to visualize 
- projection (int | None) – Index of flat dimension (e.g. 2 for z axis), gets automatically determined if not given 
 
 
- ogstools.plot.subplot(mesh, variable, ax, levels=None, **kwargs)[source]#
- Plot the variable field of a mesh on a matplotlib.axis. 
Submodules#
- ogstools.plot.animation module
- ogstools.plot.contourplots module
- ogstools.plot.contourplots_pv module
- ogstools.plot.features module
- ogstools.plot.heatmaps module
- ogstools.plot.levels module
- ogstools.plot.lineplots module
- ogstools.plot.plot_setup module- PlotSetup- PlotSetup.combined_colorbar
- PlotSetup.custom_cmap
- PlotSetup.dpi
- PlotSetup.min_ax_aspect
- PlotSetup.max_ax_aspect
- PlotSetup.invert_colorbar
- PlotSetup.layout
- PlotSetup.material_names
- PlotSetup.num_levels
- PlotSetup.num_streamline_interp_pts
- PlotSetup.vmax
- PlotSetup.vmin
- PlotSetup.__init__()
- PlotSetup.show_element_edges
- PlotSetup.log_scaled
- PlotSetup.show_region_bounds
- PlotSetup.tick_pad
- PlotSetup.tick_length
- PlotSetup.fontsize
- PlotSetup.linewidth
- PlotSetup.label_split
- PlotSetup.spatial_unit
- PlotSetup.time_unit
- PlotSetup.from_dict()
- PlotSetup.reset()
- PlotSetup.set_units()
 
 
- ogstools.plot.plot_setup_defaults module
- ogstools.plot.shared module
- ogstools.plot.utils module
- ogstools.plot.vectorplots module
 
    