Graphics#
- echopop.graphics.plot_age_length_heatmap(data: DataArray, include_filter: dict[str, Any] | None = None, exclude_filter: dict[str, Any] | None = None, replace_value=None, axis_kwargs: dict[str, Any] | None = None, plot_kwargs: dict[str, Any] | None = None, colorbar_kwargs: dict[str, Any] | None = None, imshow_kwargs: dict[str, Any] | None = None, savepath: Path | None = None, savefig_kwargs: dict[str, Any] | None = None) None#
Plot an age-length heatmap from a DataFrame.
- Parameters:
- datapandas.DataFrame
DataFrame indexed by
'length_bin'and with columns'age_bin'.- include_filterdict, optional
Dictionary of filters to include specific data. Passed to
echopop.utils.apply_filters().- exclude_filterdict, optional
Dictionary of filters to exclude specific data. Passed to
echopop.utils.apply_filters().- replace_valueany, optional
Value to use for missing or filtered data.
- axis_kwargsdict, optional
Additional keyword arguments for axis formatting (e.g., labels). Example:
axis_kwargs={'xlabel': 'Age', 'ylabel': 'Length'}- plot_kwargsdict, optional
Additional keyword arguments for
matplotlib.pyplot.subplots().- colorbar_kwargsdict, optional
Additional keyword arguments for
matplotlib.pyplot.colorbar().- imshow_kwargsdict, optional
Additional keyword arguments for
matplotlib.axes.Axes.imshow().- save_pathpathlib.Path, optional
Filepath for saving the figure.
- savefig_kwargsdict, optional
Keyword arguments used by
matplotlib.pyplot.savefig()for saving the figure to the associated save filepath.
- Returns:
- None
Notes
All keyword argument dictionaries are optional and are passed directly to the underlying plotting functions. If a keyword is present in both a specific kwargs dict and
plot_kwargs, the value inplot_kwargstakes precedence.Examples
>>> plot_age_length_heatmap(df, axis_kwargs={'xlabel': 'Age', 'ylabel': 'Length'})
- echopop.graphics.plot_kriged_mesh(data: DataFrame | GeoDataFrame, variable: str, projection: str = 'EPSG:4326', coordinate_names: tuple[str, str] = ('longitude', 'latitude'), plot_type: Literal['hexbin', 'pcolormesh', 'scatter'] = 'hexbin', scatter_kwargs: dict[str, Any] | None = None, hexbin_kwargs: dict[str, Any] | None = None, pseudocolormesh_kwargs: dict[str, Any] | None = None, coast_kwargs: dict[str, Any] | None = None, axis_kwargs: dict[str, Any] | None = None, plot_kwargs: dict[str, Any] | None = None, colorbar_kwargs: dict[str, Any] | None = None, savepath: Path | None = None, savefig_kwargs: dict[str, Any] | None = None) None#
Plot a kriged mesh or survey data using various plot types.
- Parameters:
- datapandas.DataFrame or geopandas.GeoDataFrame
Input data with coordinates and the variable to plot.
- variablestr
Name of the column to plot.
- projectionstr, default=’EPSG:4326’
CRS for the plot. This should be either a projected or geodetic coordinate system definition compatible with with
geopandas.GeoDataFrame.- coordinate_namestuple[str], default=(‘longitude’, ‘latitude’)
Names of the coordinate columns. This is a tuple with an expected order of
'x'and then'y'.- plot_type{‘hexbin’, ‘pcolormesh’, ‘scatter’}, default=’hexbin’
Type of plot to produce. Options are:
‘hexbin’: Creates a hexagonal binned plot using
matplotlib.pyplot.hexbin(), which visualizes a summary statistic defined by the user (via thereduce_C_functionargument, which defaults tonumpy.mean()) over a two-dimensional grid of hexagons. The plotted hexagonal bins can be configured using keyword arguments supplied to thehexbin_kwargsargument.‘pcolormesh’: Interpolates the variable onto a regular grid using
verde.Chainfor spatial interpolation that returns anxarray.DataArray. The resulting grid is then displayed as a pseudocolor mesh usingxarray.DataArray.plot.pcolormesh(). The plotted pseudocolor mesh can be configured using keyword arguments supplied to thepseudocolormesh_kwargsargument.‘scatter’: Plots each data point individually using
matplotlib.axes.Axes.scatter()points based on the variable value. The plotted points can be configured using keyword arguments supplied to thescatter_kwargsargument.
- scatter_kwargsdict, optional
Additional keyword arguments passed directly to
matplotlib.pyplot.scatter()ifplot_type='scatter'. For example, you can control marker size, color, alpha, etc. Example:scatter_kwargs={'s': 20, 'c': 'red', 'alpha': 0.7}- hexbin_kwargsdict, optional
Additional keyword arguments passed directly to
matplotlib.pyplot.hexbin()ifplot_type='hexbin'. For example, you can control grid size, colormap, etc. Example:hexbin_kwargs={'gridsize': 50, 'cmap': 'viridis'}- pseudocolormesh_kwargsdict, optional
Additional keyword arguments passed to the mesh interpolation and to
xarray.DataArray.plot.pcolormesh()ifplot_type='pcolormesh'. For example, you can specify mesh spacing, colormap, shading, etc. Example:pseudocolormesh_kwargs={'spacing': 0.01, 'cmap': 'plasma'}- coast_kwargsdict, optional
Additional keyword arguments passed to the coastline plotting function such as
cartopy.mpl.geoaxes.GeoAxes.add_feature(). These control the appearance of the coastline overlay. Example:coast_kwargs={'edgecolor': 'black', 'linewidth': 0.5}- axis_kwargsdict, optional
Additional keyword arguments passed to axis formatting functions (e.g., setting axis limits, labels, or grid). These are merged with any defaults and passed to the axis/axes object. Example:
axis_kwargs={'xlabel': 'Longitude', 'ylabel': 'Latitude', 'xlim': (-130, -120)}- plot_kwargsdict, optional
Additional keyword arguments passed to the main plotting function, depending on
plot_type. These are merged with the specific kwargs above and can override them. Example:plot_kwargs={'alpha': 0.8}- colorbar_kwargsdict, optional
Additional keyword arguments passed to
matplotlib.pyplot.colorbar()for customizing the colorbar. These control label, orientation, ticks, etc. Example:colorbar_kwargs={'label': 'Biomass (kg)', 'orientation': 'vertical'}- save_pathPath, optional
Filepath for saving the figure.
- savefig_kwargsdict, optional
Keyword arguments used by
matplotlib.pyplot.savefig()for saving the figure to the associated save filepath.
- Returns:
- None
Notes
All keyword argument dictionaries are optional. If provided, they are passed directly to the underlying matplotlib or Cartopy plotting functions. If the same keyword is present in both a specific kwargs dict (e.g.,
scatter_kwargs) andplot_kwargs, the value inplot_kwargstakes precedence.Examples
>>> plot_kriged_mesh(df, 'biomass', plot_type='hexbin', ... hexbin_kwargs={'gridsize': 40, 'cmap': 'viridis'}, ... coast_kwargs={'edgecolor': 'gray'}, ... colorbar_kwargs={'label': 'Biomass (kg)'})
- echopop.graphics.plot_transect_map(data: DataFrame | GeoDataFrame, variable: str, projection: str = 'EPSG:4326', coordinate_names: tuple[str, str] = ('longitude', 'latitude'), scatter_kwargs: dict[str, Any] | None = None, transect_kwargs: dict[str, Any] | None = None, coast_kwargs: dict[str, Any] | None = None, axis_kwargs: dict[str, Any] | None = None, plot_kwargs: dict[str, Any] | None = None, colorbar_kwargs: dict[str, Any] | None = None, savepath: Path | None = None, savefig_kwargs: dict[str, Any] | None = None) None#
Plot survey transects and variable values on a map.
- Parameters:
- datapandas.DataFrame or geopandas.GeoDataFrame
Input data with coordinates and variable to plot.
- variablestr
Name of the column to plot.
- projectionstr, default=’EPSG:4326’
CRS for the plot. This should be either a projected or geodetic coordinate system definition compatible with
geopandas.GeoDataFrame.- coordinate_namestuple[str], default=(‘longitude’, ‘latitude’)
Names of the coordinate columns. This is a tuple with an expected order of
'x'and then'y'.- scatter_kwargsdict, optional
Additional keyword arguments passed directly to
matplotlib.axes.Axes.scatter(). For example, you can control marker size, color, alpha, etc., such as:scatter_kwargs={'s': 20, 'c': 'red', 'alpha': 0.7}- transect_kwargsdict, optional
Additional keyword arguments passed to
geopandas.GeoDataFrame.plot()for transect lines. For example, you can control line color, width, style, etc. such as:transect_kwargs={'color': 'black', 'linewidth': 1.5}- coast_kwargsdict, optional
Additional keyword arguments passed to the coastline plotting function such as
cartopy.mpl.geoaxes.GeoAxes.add_feature(). These control the appearance of the coastline overlay. Example:coast_kwargs={'edgecolor': 'black', 'linewidth': 0.5}- axis_kwargsdict, optional
Additional keyword arguments passed to axis formatting functions (e.g., setting axis limits, labels, or grid). These are merged with any defaults and passed to the axis/axes object. Example:
axis_kwargs={'xlabel': 'Longitude', 'ylabel': 'Latitude', 'xlim': (-130, -120)}- plot_kwargsdict, optional
Additional keyword arguments passed to the main plotting function, depending on
plot_type. These are merged with the specific kwargs above and can override them. Example:plot_kwargs={'alpha': 0.8}- colorbar_kwargsdict, optional
Additional keyword arguments passed to
matplotlib.pyplot.colorbar()for customizing the colorbar. These control label, orientation, ticks, etc. Example:colorbar_kwargs={'label': 'Biomass (kg)', 'orientation': 'vertical'}- save_pathPath, optional
Filepath for saving the figure.
- savefig_kwargsdict, optional
Keyword arguments used by
matplotlib.pyplot.savefig()for saving the figure to the associated save filepath.
- Returns:
- None
Notes
All keyword argument dictionaries are optional and are passed directly to the underlying plotting functions. If a keyword is present in both a specific kwargs dict and
plot_kwargs, the value inplot_kwargstakes precedence.Examples
>>> plot_transect_map(df, 'biomass', ... scatter_kwargs={'s': 10, 'c': 'blue'}, ... transect_kwargs={'color': 'black', 'linewidth': 1.5}, ... coast_kwargs={'edgecolor': 'gray'}, ... colorbar_kwargs={'label': 'Biomass (kg)'})
- class echopop.graphics.Diagnostics(json_theme: dict[str, Any] | None = None)#
Diagnostics plotting utilities for survey and mesh data.
- Parameters:
- json_themedict, optional
A Bokeh theme dictionary to apply to plots.
Methods
plot_mesh_cropping(mesh_data, ...[, projection])Plot the results of the crop meshing.
plot_nasc_map(transect_data[, projection])Plot NASC (Nautical Area Scattering Coefficient) values for transects.
plot_stratified_results(stratum_results)Plot stratified biomass results with error bars and relative bias.
plot_transect_mesh_regions(transect_data, ...)Plot the mesh region assignment to transects.
- class echopop.graphics.VariogramGUI(data: DataFrame, lag_resolution: float, n_lags: int, coordinates: tuple, variogram_parameters: dict[str, Any] | None = None)#
Interactive graphical user interface for variogram analysis and model fitting.
The
VariogramGUIclass provides an interactive, tabbed interface for computing, visualizing, and optimizing empirical and theoretical variograms from spatial data. It is designed for use in Jupyter environments and leverages ipywidgets, holoviews, and bokeh for dynamic plotting and user input.- Parameters:
- datapandas.DataFrame
Input spatial dataset containing coordinate columns and variables for variogram analysis.
- lag_resolutionfloat
The distance interval for each lag bin in the variogram calculation.
- n_lagsint
Number of lag bins to use for empirical variogram computation.
- coordinatestuple of str
Names of the columns in
datarepresenting spatial coordinates, e.g.("longitude", "latitude").- variogram_parametersdict, optional
Dictionary of initial variogram model parameters and their default values.
- Attributes:
optimized_parametersReturn the best-fit, optimized variogram parameters.
Notes
All computation and plotting is handled internally; users interact only through the GUI.
For advanced scripting or batch processing, use the
echopop.geostatistics.Variogramclass directly.
Examples
Instantiate the class in a Jupyter notebook and display the GUI by evaluating the instance:
>>> gui = VariogramGUI( ... data=survey_df, ... lag_resolution=5.0, ... n_lags=15, ... coordinates=("longitude", "latitude"), ... variogram_parameters={"sill": {"value": 2.0}, "nugget": {"value": 0.1}} ... ) >>> gui # Displays the interactive GUI