larvaworld.lib.reg.graph
Graph/plotting registry for the larvaworld package. This module provides a class for managing and creating plots and graphs.
Classes
Registry for managing and creating plots and graphs. |
Module Contents
- class larvaworld.lib.reg.graph.GraphRegistry
Registry for managing and creating plots and graphs.
Manages graph functions, graphgroups (collections of related plots), and provides methods for batch plot creation during analysis.
- Attributes:
dict: Dictionary of graph functions required_data_dict: Dictionary of required data for each graph function graphgroups: Dictionary of graphgroups, each containing plot specifications
- Example:
>>> graph_reg = GraphRegistry() >>> graph_reg.exists('trajectories') # Check if graph exists >>> plots = graph_reg.run_group('traj') # Run trajectory graphgroup >>> graph_reg.eval_graphgroups(['general', 'endpoint'], save_to='plots/')
- dict
- required_data_dict
- graphgroups
- property ks: larvaworld.lib.util.SuperList
Returns a sorted list of the keys of the graph functions.
- exists(ID: str) bool
Checks if a graph function with the given ID exists.
- group_exists(gID: str) bool
Checks if a graphgroup with the given ID exists.
- eval_graphgroups(graphgroups: list[str] | dict, save_to: str | None = None, **kws: Any) larvaworld.lib.util.AttrDict
Evaluates a list of graphgroups.
Args: - graphgroups (list): A list of graphgroups to evaluate. - save_to (str, optional): The directory to save the plots to. Defaults to None. - **kws: Additional keyword arguments to pass to the graph functions.
Returns: - dict: A dictionary of evaluated graphgroups.
- grouplist_to_dict(groups: list | dict) larvaworld.lib.util.AttrDict | dict
Converts a list of graphgroups to a dictionary.
Args: - groups (list): A list of graphgroups to convert.
Returns: - dict: A dictionary of graphgroups.
- eval_entries(entries: list[dict], **kwargs: Any) larvaworld.lib.util.AttrDict
Evaluates a list of graph entries.
Args: - entries (list): A list of graph entries to evaluate.
Returns: - dict: A dictionary of evaluated graph entries.
- run(ID: str, **kwargs: Any) Any
Runs a graph function with the given ID.
Args: - ID (str): The ID of the graph function to run.
Returns: - plot.Plot: The plot created by the graph function.
- run_group(gID: str, **kwargs: Any) larvaworld.lib.util.AttrDict
Runs a graphgroup with the given ID.
Args: - gID (str): The ID of the graphgroup to run.
Returns: - dict: A dictionary of plots created by the graphgroup.
- entry(ID: str, name: str | None = None, **kwargs: Any) dict
Creates a graph entry with the given ID and optional name.
Args: - ID (str): The ID of the graph function to create an entry for. - name (str, optional): The name of the graph entry. Defaults to None.
Returns: - dict: A dictionary containing the key, plotID, and arguments for the graph entry.
- model_tables(mIDs: list[str], dIDs: list[str] | None = None, save_to: str | None = None, **kwargs: Any) larvaworld.lib.util.AttrDict
Creates tables for the given model IDs.
Args: - mIDs (list): A list of model IDs to create tables for. - dIDs (list, optional): A list of display IDs to use for the model IDs. Defaults to None. - save_to (str, optional): The directory to save the tables to. Defaults to None.
Returns: - dict: A dictionary of tables created for the given model IDs.
- model_summaries(mIDs: list[str], save_to: str | None = None, **kwargs: Any) dict
Creates summary plots for the given model IDs.
Args: - mIDs (list): A list of model IDs to create summaries for. - save_to (str, optional): The directory to save the summaries to. Defaults to None.
Returns: - dict: A dictionary of summary plots created for the given model IDs.
- store_model_graphs(mIDs: list[str], dir: str) larvaworld.lib.util.AttrDict
Stores model graphs for the given model IDs.
Args: - mIDs (list): A list of model IDs to store graphs for. - dir (str): The directory to store the graphs in.
Returns: - dict: A dictionary of stored model graphs.
- source_graphgroup(source_ID: str, pos: tuple[float, float] | None = None, **kwargs: Any) larvaworld.lib.util.AttrDict
Creates a graphgroup consisting of plots related to a given food/odor source.
Args: - source_ID (str): The ID of the source to create a graphgroup for. - pos (tuple, optional): The position of the source. Defaults to None.
Returns: - dict: A dictionary of plot entries for source-related plotting.
- get_analysis_graphgroups(exp: str, sources: dict[str, Any], **kwargs: Any) larvaworld.lib.util.AttrDict | dict
Determines the plots to be created during the analysis of a given experiment/simulation.
Args: - exp (str): The experiment that has been completed for which the analysis is requested.
The string that defines the type of experiment is associated with one or more graphgroups by their keys.
- sources (dict): A dictionary of the IDs and positions of any food/odor sources in the arena.
For certain experiments these are needed to create source related plots.
Returns: - list: All graphgroups (by their keys) and optionally any single graphs to be created (evaluated) during analysis
- build_graphgroups() larvaworld.lib.util.AttrDict
Creates a dictionary of lists/groups of plots/graphs. Each such group of plots (graphgroup) can be accessed by a key so that all the plots included in the group can be created. The analysis of a given experiment/simulation can be associated with several such graphgroups in the get_analysis_graphgroups method.