mescal.plot =========== .. py:module:: mescal.plot Classes ------- .. autoapisummary:: mescal.plot.Plot Functions --------- .. autoapisummary:: mescal.plot.plot_contribution_analysis Module Contents --------------- .. py:class:: Plot(df_impact_scores: pandas.DataFrame, esm_results_tech: pandas.DataFrame = None, esm_results_res: pandas.DataFrame = None, lifetime: pandas.DataFrame = None) Class to plot LCA indicators and ESM results. Initialize the Plot class. :param df_impact_scores: dataframe of LCA indicators obtained with the compute_impact_scores method of the ESM class. :param esm_results_tech: dataframe of ESM results for technologies. It should have the following columns: 'Run' (iteration number), 'Name' (technology name), 'Capacity' (installed capacity of the technology), 'Production' (annual production of the technology). :param esm_results_res: dataframe of ESM results for resources. It should have the following columns: 'Run' (iteration number), 'Name' (resource name), 'Import' (annual import of the resource). :param lifetime: dataframe of lifetime of technologies. .. py:method:: plot_indicators_of_resources_for_one_impact_category(resources_list: list[str], impact_category: tuple, metadata: dict = None, filename: str = None, saving_format: str = 'png', saving_path: str = None, show_plot: bool = True, contributions_total_score: bool = False) -> None Plot operation LCA indicators for a set of resources for a given impact category. :param resources_list: list of technologies to plot. They should have the same operation/infrastructure units to have a meaningful comparison :param impact_category: impact category to plot (brightway format) :param metadata: dictionary with metadata to include in the plot. It can include 'resources_type', 'unit', 'impact_category_unit'. :param filename: name of the file to save the plot. If None, the plot is not saved. :param saving_format: format to save the plot, can be 'png', 'jpeg', 'pdf', 'html', etc. Default is 'png'. :param saving_path: path to save the plot under the form 'path/to/folder/'. If None, the plot is saved in the current directory. :param show_plot: if True, the plot is shown in the notebook. :param contributions_total_score: if True, the contributions of all categories to the total score are shown. :return: None (plot is shown and/or saved) .. py:method:: plot_indicators_of_resources_for_several_impact_categories(resources_list: list[str], impact_categories_list: list[tuple] = None, impact_categories_units: dict[tuple] = None, filename: str = None, saving_format: str = 'png', saving_path: str = None, show_plot: bool = True) -> None Plot LCA indicators for a set of resources for a set of impact categories. :param resources_list: list of technologies to plot. They should have the same operation/infrastructure units to have a meaningful comparison :param impact_categories_list: list of impact category to plot (brightway format). Not needed if impact_categories_units is provided. :param impact_categories_units: dictionary with physical units for each impact category. Not needed if the impact categories are available in the current brightway project. :param filename: name of the file to save the plot. If None, the plot is not saved. :param saving_format: format to save the plot, can be 'png', 'jpeg', 'pdf', 'html', etc. Default is 'png'. :param saving_path: path to save the plot under the form 'path/to/folder/'. If None, the plot is saved in the current directory. :param show_plot: if True, the plot is shown in the notebook. :return: None (plot is shown and/or saved) .. py:method:: plot_indicators_of_technologies_for_one_impact_category(technologies_list: list[str], impact_category: tuple, metadata: dict = None, filename: str = None, saving_format: str = 'png', saving_path: str = None, show_plot: bool = True, contributions_total_score: bool = False) -> None Plot operation and infrastructure LCA indicators for a set of technologies for a given impact category. If decommission scores are provided, they wil be accounted in the infrastructure scores. :param technologies_list: list of technologies to plot. They should have the same operation/infrastructure units to have a meaningful comparison :param impact_category: impact category to plot (brightway format) :param metadata: dictionary with metadata to include in the plot. It can include 'technologies_type', 'operation_unit', 'construction_unit', 'impact_category_unit'. :param filename: name of the file to save the plot. If None, the plot is not saved. :param saving_format: format to save the plot, can be 'png', 'jpeg', 'pdf', 'html', etc. Default is 'png'. :param saving_path: path to save the plot under the form 'path/to/folder/'. If None, the plot is saved in the current directory. :param show_plot: if True, the plot is shown in the notebook. :param contributions_total_score: if True, the contributions of all categories to the total score are shown. :return: None (plot is shown and/or saved) .. py:method:: plot_indicators_of_technologies_for_several_impact_categories(technologies_list: list[str], impact_categories_list: list[tuple] = None, impact_categories_units: dict[tuple] = None, filename: str = None, saving_format: str = 'png', saving_path: str = None, show_plot: bool = True) -> None Plot operation and infrastructure LCA indicators for a set of technologies for a set of impact categories. If decommission scores are provided, they wil be accounted in the infrastructure scores. :param technologies_list: list of technologies to plot. They should have the same operation/infrastructure units to have a meaningful comparison :param impact_categories_list: list of impact category to plot (brightway format). Not needed if impact_categories_units is provided. :param impact_categories_units: dictionary with physical units for each impact category. Not needed if the impact categories are available in the current brightway project. :param filename: name of the file to save the plot. If None, the plot is not saved. :param saving_format: format to save the plot, can be 'png', 'jpeg', 'pdf', 'html', etc. Default is 'png'. :param saving_path: path to save the plot under the form 'path/to/folder/'. If None, the plot is saved in the current directory. :param show_plot: if True, the plot is shown in the notebook. :return: None (plot is shown and/or saved) .. py:method:: plot_results(impact_categories_list: list[tuple] = None, impact_categories_units: dict[tuple] = None, split_by: str = 'Type', N_highest_contributors: int = 0, normalized: bool = False, n_run: int = 0, filename: str = None, saving_format: str = 'png', saving_path: str = None, show_plot: bool = True) -> None Plot the environmental impact results :param impact_categories_list: list of impact categories to plot (brightway format). Not needed if impact_categories_units is provided. :param impact_categories_units: dictionary with physical units for each impact category. Not needed if the impact categories are available in the current brightway project. :param split_by: can be 'Type' (for life-cycle phases) or 'Name' (for technologies and resources) :param N_highest_contributors: if split_by is 'Name', the number of highest contributors to show :param normalized: if True, the impacts are normalized by the total impact of the category :param n_run: number of the run to plot :param filename: name of the file to save the plot. If None, the plot is not saved. :param saving_format: format to save the plot, can be 'png', 'jpeg', 'pdf', 'html', etc. Default is 'png'. :param saving_path: path to save the plot under the form 'path/to/folder/'. If None, the plot is saved in the current directory. :param show_plot: if True, the plot is shown in the notebook. :return: None (plot is shown and/or saved) .. py:attribute:: df_impact_scores .. py:attribute:: esm_results_res :value: None .. py:attribute:: esm_results_tech :value: None .. py:attribute:: lifetime :value: None .. py:function:: plot_contribution_analysis(df: pandas.DataFrame, unit_type_groups_dict: dict, contribution_type: str = 'processes', impact_categories_list: list[str] = None, act_types: list[str] = None, saving_path: str = None, saving_format: str = 'png', show_plot: bool = False, esm_units: list[str] = None, threshold: float = 0.05, cell_size: float = 0.8, min_fig_width: float = 10, min_fig_height: float = 6, dpi: int = 300, annot_fmt: str = '.1%') -> None Generate heatmap visualizations for contribution analysis :param df: Processed contribution data with impact_share column :param unit_type_groups_dict: Mapping of (ESM, Type) to technology names :param contribution_type: Type of contribution analysis: 'processes' or 'emissions' :param impact_categories_list: List of impact categories to plot. If None, plots all categories. :param act_types: List of activity types. If None, includes all types present in the data. :param saving_path: Output directory for saving plots. If None, plots are not saved. :param saving_format: Format for saved plots (e.g., 'png', 'pdf') :param show_plot: Whether to display plots in the notebook :param esm_units: List of ESM units to include. If None, includes all available units. :param threshold: Threshold for grouping small contributions into 'Others' :param cell_size: Size per cell in inches for figure sizing :param min_fig_width: Minimum figure width in inches :param min_fig_height: Minimum figure height in inches :param dpi: Resolution for saved figures :param annot_fmt: Format string for heatmap annotations :return: None (plots are shown and/or saved)