dibisoplot#

class dibisoplot.dibisoplot.DataStatus(*values)#

Bases: Enum

Status of the data.

ERROR = 3#
NOT_FETCHED = 0#
NO_DATA = 2#
OK = 1#
class dibisoplot.dibisoplot.Dibisoplot(entity_id, year: int | None = None, barcornerradius: int = 10, dynamic_height: bool = True, dynamic_min_height: int | float = 150, dynamic_height_per_bar: int | float = 25, height: int = 600, language: str = 'en', legend_pos: dict = None, main_color: str = 'blue', margin: dict = None, max_entities: int | None = 1000, max_plotted_entities: int = 25, template: str = 'simple_white', text_position: str = 'outside', title: str | None = None, width: int = 800)#

Bases: object

Base class for generating plots and tables from data fetched from various APIs. The fetch methods are located in each child classes. This class is not designed to be called directly but rather to provide general methods to the different plot types.

Variables:
  • orientation – Orientation for plots (‘v’ for vertical, ‘h’ for horizontal).

  • figure_file_extension – File extension of the figure (pdf, tex…).

  • default_dynamic_bar_width – Default width for bars in plots when the height is set dynamically.

  • default_height – Default height for plots.

  • default_legend_pos – Default position for the legend.

  • default_margin – Default margins for plots.

__init__(entity_id, year: int | None = None, barcornerradius: int = 10, dynamic_height: bool = True, dynamic_min_height: int | float = 150, dynamic_height_per_bar: int | float = 25, height: int = 600, language: str = 'en', legend_pos: dict = None, main_color: str = 'blue', margin: dict = None, max_entities: int | None = 1000, max_plotted_entities: int = 25, template: str = 'simple_white', text_position: str = 'outside', title: str | None = None, width: int = 800)#

Initialize the Biso class with the given parameters.

Parameters:
  • entity_id (str) – The HAL collection identifier. This usually refers to the entity id acronym.

  • year (int | none, optional) – The year for which to fetch data. If None, uses the current year.

  • barcornerradius (int, optional) – Corner radius for bars in plots.

  • dynamic_height (bool, optional) – Whether to use dynamic height for the plot. Only implemented for horizontal bar plots.

  • dynamic_min_height (int | float, optional) – Minimum height for the plot when the height is set dynamically.

  • dynamic_height_per_bar (int | float, optional) – Height per bar for plots when the height is set dynamically.

  • height (int, optional) – Height of the plot.

  • language (str, optional) – Language for the plot. Default to ‘fr’.

  • legend_pos (dict, optional) – Position of the legend.

  • main_color (str, optional) – Main color for the plot.

  • margin (dict, optional) – Margins for the plot.

  • max_entities (int | None, optional) – Default maximum number of entities used to create the plot. Default 1000. Set to None to disable the limit. This value limits the number of queried entities when doing analysis. For example, when creating the collaboration map, it limits the number of works to query from HAL to extract the collaborating institutions from.

  • max_plotted_entities (int, optional) – Maximum number of bars in the plot or rows in the table. Default to 25.

  • template (str, optional) – Template for the plot.

  • text_position (str, optional) – Position of the text on bars.

  • title (str | None, optional) – Title of the plot.

  • width (int, optional) – Width of the plot.

dataframe_to_longtable(table_df, alignments: list | None = None, caption: str | None = None, label: str | None = None, vertical_lines: bool = True, classic_horizontal_lines: bool = False, minimal_horizontal_lines: bool = True, max_plotted_entities: int | None = None) str#

Convert a pandas DataFrame to LaTeX longtable code without document headers.

This function generates LaTeX code for a longtable from a pandas DataFrame. It handles various formatting options such as alignments, captions, labels, and lines between rows and columns.

Parameters:
  • table_df (pd.DataFrame) – pandas DataFrame to convert.

  • alignments (list | None, optional) – List of column alignments (e.g., [‘l’, ‘c’, ‘r’]).

  • caption (str | None , optional) – Caption for the table.

  • label (str | None, optional) – Label for referencing the table.

  • vertical_lines (bool, optional) – Whether to include vertical lines between columns.

  • classic_horizontal_lines (bool, optional) – Whether to include horizontal lines between rows in a classic style.

  • minimal_horizontal_lines (bool, optional) – Whether to include minimal horizontal lines between rows.

  • max_plotted_entities (int | None, optional) – Maximum number of entities to show in the table. If None, show all entities in the table.

Returns:

LaTeX code for the longtable (without document headers).

Return type:

str

Raises:
  • AttributeError – If both classic_horizontal_lines and minimal_horizontal_lines are True.

  • ValueError – If the number of alignments does not match the number of columns.

default_dynamic_bar_width = 0.7#
default_height = 600#
default_legend_pos = {'x': 1, 'xanchor': 'right', 'y': 0, 'yanchor': 'bottom'}#
default_margin = {'b': 15, 'l': 15, 'pad': 4, 'r': 15, 't': 15}#
figure_file_extension = 'pdf'#
generate_plot_info(hide_max_entities_reached_warning: bool = False, hide_n_entities_warning: bool = False)#

Generate the plot info. This information is used to print a warning on the report.

Parameters:
  • hide_max_entities_reached_warning (bool, optional) – If True, the warning about the maximum number of entities processed is not displayed.

  • hide_n_entities_warning (bool, optional) – If True, the warning about the number of entities found is not displayed.

get_error_latex() str#

Create the error LaTeX code.

get_error_plot() Figure#

Create the error plot.

get_figure() Figure#

Generate a bar plot based on the fetched data.

Returns:

The plotly figure.

Return type:

go.Figure

get_no_data_latex() str#

Create the error LaTeX code.

get_no_data_plot() Figure#

Create the error plot.

orientation = 'v'#