ergodic_insurance.visualization_infra package

Submodules

ergodic_insurance.visualization_infra.figure_factory module

Figure factory for creating standardized plots with consistent styling.

This module provides a factory class for creating various types of plots with automatic styling, spacing, and formatting applied consistently.

class FigureFactory(style_manager: StyleManager | None = None, theme: Theme = Theme.DEFAULT, auto_apply: bool = True)[source]

Bases: object

Factory for creating standardized figures with consistent styling.

This class provides methods to create various types of plots with automatic application of themes, consistent formatting, and proper spacing.

Example

>>> factory = FigureFactory(theme=Theme.PRESENTATION)
>>> fig, ax = factory.create_line_plot(
...     x_data=[1, 2, 3, 4],
...     y_data=[10, 20, 15, 25],
...     title="Revenue Growth",
...     x_label="Quarter",
...     y_label="Revenue ($M)"
... )
>>> # Create multiple subplots
>>> fig, axes = factory.create_subplots(
...     rows=2, cols=2,
...     size_type="large",
...     subplot_titles=["Q1", "Q2", "Q3", "Q4"]
... )
create_figure(size_type: str = 'medium', orientation: str = 'landscape', dpi_type: str = 'screen', title: str | None = None) Tuple[Figure, Axes][source]

Create a basic figure with styling applied.

Parameters:
  • size_type (str) – Size preset (small, medium, large, blog, technical, presentation)

  • orientation (str) – Figure orientation (landscape or portrait)

  • dpi_type (str) – DPI type (screen, web, print)

  • title (Optional[str]) – Optional figure title

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_subplots(rows: int = 1, cols: int = 1, size_type: str = 'large', dpi_type: str = 'screen', title: str | None = None, subplot_titles: List[str] | None = None, **kwargs) Tuple[Figure, Axes | ndarray][source]

Create subplots with consistent styling.

Parameters:
  • rows (int) – Number of subplot rows

  • cols (int) – Number of subplot columns

  • size_type (str) – Size preset

  • dpi_type (str) – DPI type

  • title (Optional[str]) – Main figure title

  • subplot_titles (Optional[List[str]]) – Titles for each subplot

  • **kwargs – Additional arguments for plt.subplots

Return type:

Tuple[Figure, Union[Axes, ndarray]]

Returns:

Tuple of (figure, axes array)

create_line_plot(x_data: List | ndarray | Series, y_data: List | ndarray | Series | Dict[str, List | ndarray], title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', show_legend: bool = True, show_grid: bool = True, markers: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a line plot with automatic formatting.

Parameters:
  • x_data (Union[List, ndarray, Series]) – X-axis data

  • y_data (Union[List, ndarray, Series, Dict[str, Union[List, ndarray]]]) – Y-axis data (can be multiple series as dict)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Series labels for legend

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • show_legend (bool) – Whether to show legend

  • show_grid (bool) – Whether to show grid

  • markers (bool) – Whether to add markers to lines

  • **kwargs – Additional arguments for plot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_bar_plot(categories: List | ndarray, values: List | ndarray | Dict[str, List | ndarray], title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', orientation: str = 'vertical', show_values: bool = False, value_format: str = '.1f', **kwargs) Tuple[Figure, Axes][source]

Create a bar plot with automatic formatting.

Parameters:
  • categories (Union[List, ndarray]) – Category labels

  • values (Union[List, ndarray, Dict[str, Union[List, ndarray]]]) – Values to plot (can be multiple series as dict)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Series labels for legend

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • orientation (str) – Bar orientation (vertical or horizontal)

  • show_values (bool) – Whether to show value labels on bars

  • value_format (str) – Format string for value labels

  • **kwargs – Additional arguments for bar plot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_scatter_plot(x_data: List | ndarray, y_data: List | ndarray, title: str | None = None, x_label: str | None = None, y_label: str | None = None, size_type: str = 'medium', dpi_type: str = 'screen', colors: List | ndarray | None = None, sizes: List | ndarray | None = None, labels: List[str] | None = None, show_colorbar: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a scatter plot with automatic formatting.

Parameters:
  • x_data (Union[List, ndarray]) – X-axis data

  • y_data (Union[List, ndarray]) – Y-axis data

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • colors (Union[List, ndarray, None]) – Optional colors for points (for continuous coloring)

  • sizes (Union[List, ndarray, None]) – Optional sizes for points

  • labels (Optional[List[str]]) – Optional labels for points

  • show_colorbar (bool) – Whether to show colorbar when colors provided

  • **kwargs – Additional arguments for scatter

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_histogram(data: List | ndarray | Series, title: str | None = None, x_label: str | None = None, y_label: str = 'Frequency', bins: int | str = 'auto', size_type: str = 'medium', dpi_type: str = 'screen', show_statistics: bool = False, show_kde: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a histogram with automatic formatting.

Parameters:
  • data (Union[List, ndarray, Series]) – Data to plot

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (str) – Y-axis label

  • bins (Union[int, str]) – Number of bins or method

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • show_statistics (bool) – Whether to show mean/median lines

  • show_kde (bool) – Whether to overlay KDE

  • **kwargs – Additional arguments for hist

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_heatmap(data: ndarray | DataFrame, title: str | None = None, x_labels: List[str] | None = None, y_labels: List[str] | None = None, x_label: str | None = None, y_label: str | None = None, size_type: str = 'medium', dpi_type: str = 'screen', cmap: str = 'RdBu_r', show_values: bool = True, value_format: str = '.2f', **kwargs) Tuple[Figure, Axes][source]

Create a heatmap with automatic formatting.

Parameters:
  • data (Union[ndarray, DataFrame]) – 2D data array or DataFrame

  • title (Optional[str]) – Plot title

  • x_labels (Optional[List[str]]) – Labels for x-axis

  • y_labels (Optional[List[str]]) – Labels for y-axis

  • x_label (Optional[str]) – X-axis title

  • y_label (Optional[str]) – Y-axis title

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • cmap (str) – Colormap name

  • show_values (bool) – Whether to show values in cells

  • value_format (str) – Format string for cell values

  • **kwargs – Additional arguments for imshow

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_box_plot(data: List[List] | Dict[str, List] | DataFrame, title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', orientation: str = 'vertical', show_means: bool = True, **kwargs) Tuple[Figure, Axes][source]

Create a box plot with automatic formatting.

Parameters:
  • data (Union[List[List], Dict[str, List], DataFrame]) – Data for box plot (list of lists, dict, or DataFrame)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Labels for each box

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • orientation (str) – Plot orientation (vertical or horizontal)

  • show_means (bool) – Whether to show mean markers

  • **kwargs – Additional arguments for boxplot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

format_axis_currency(ax: Axes, axis: str = 'y', abbreviate: bool = True, decimals: int = 0) None[source]

Format axis labels as currency.

Parameters:
  • ax (Axes) – Matplotlib axes

  • axis (str) – Which axis to format (x or y)

  • abbreviate (bool) – Whether to abbreviate large numbers

  • decimals (int) – Number of decimal places

Return type:

None

format_axis_percentage(ax: Axes, axis: str = 'y', decimals: int = 0) None[source]

Format axis labels as percentages.

Parameters:
  • ax (Axes) – Matplotlib axes

  • axis (str) – Which axis to format (x or y)

  • decimals (int) – Number of decimal places

Return type:

None

add_annotations(ax: Axes, x: float, y: float, text: str, arrow: bool = True, offset: Tuple[float, float] = (10, 10), **kwargs) None[source]

Add styled annotation to plot.

Parameters:
  • ax (Axes) – Matplotlib axes

  • x (float) – X coordinate

  • y (float) – Y coordinate

  • text (str) – Annotation text

  • arrow (bool) – Whether to show arrow

  • offset (Tuple[float, float]) – Text offset from point

  • **kwargs – Additional arguments for annotate

Return type:

None

save_figure(fig: Figure, filename: str, output_type: str = 'web', **kwargs) None[source]

Save figure with appropriate DPI settings.

Parameters:
  • fig (Figure) – Figure to save

  • filename (str) – Output filename

  • output_type (str) – Output type (screen, web, print)

  • **kwargs – Additional arguments for savefig

Return type:

None

ergodic_insurance.visualization_infra.style_manager module

Style management for consistent visualization across all reports.

This module provides centralized style configuration for all visualizations, including color palettes, fonts, figure sizes, and DPI settings.

class Theme(*values)[source]

Bases: Enum

Available visualization themes.

DEFAULT = 'default'
COLORBLIND = 'colorblind'
PRESENTATION = 'presentation'
MINIMAL = 'minimal'
PRINT = 'print'
class ColorPalette(primary: str = '#0080C7', secondary: str = '#003F5C', accent: str = '#FF9800', warning: str = '#D32F2F', success: str = '#4CAF50', neutral: str = '#666666', background: str = '#FFFFFF', text: str = '#000000', grid: str = '#E0E0E0', series: List[str] = <factory>) None[source]

Bases: object

Color palette configuration for a theme.

primary

Main color for primary elements

secondary

Secondary color for supporting elements

accent

Accent color for highlights

warning

Color for warnings or negative values

success

Color for positive values or success states

neutral

Neutral gray tones

background

Background color

text

Text color

grid

Grid line color

series

List of colors for multiple data series

primary: str = '#0080C7'
secondary: str = '#003F5C'
accent: str = '#FF9800'
warning: str = '#D32F2F'
success: str = '#4CAF50'
neutral: str = '#666666'
background: str = '#FFFFFF'
text: str = '#000000'
grid: str = '#E0E0E0'
series: List[str]
class FontConfig(family: str = 'Arial', size_base: int = 11, size_title: int = 14, size_label: int = 12, size_tick: int = 10, size_legend: int = 10, weight_normal: str = 'normal', weight_bold: str = 'bold') None[source]

Bases: object

Font configuration for a theme.

family

Font family name

size_base

Base font size

size_title

Title font size

size_label

Label font size

size_tick

Tick label font size

size_legend

Legend font size

weight_normal

Normal font weight

weight_bold

Bold font weight

family: str = 'Arial'
size_base: int = 11
size_title: int = 14
size_label: int = 12
size_tick: int = 10
size_legend: int = 10
weight_normal: str = 'normal'
weight_bold: str = 'bold'
class FigureConfig(size_small: Tuple[float, float] = (6, 4), size_medium: Tuple[float, float] = (8, 6), size_large: Tuple[float, float] = (12, 8), size_blog: Tuple[float, float] = (8, 6), size_technical: Tuple[float, float] = (10, 8), size_presentation: Tuple[float, float] = (10, 7.5), dpi_screen: int = 100, dpi_web: int = 150, dpi_print: int = 300) None[source]

Bases: object

Figure size and DPI configuration.

size_small

Small figure size (width, height) in inches

size_medium

Medium figure size

size_large

Large figure size

size_blog

Blog-optimized size (8x6)

size_technical

Technical appendix size (10x8)

size_presentation

Presentation slide size

dpi_screen

DPI for screen display

dpi_web

DPI for web publishing (150)

dpi_print

DPI for print quality (300)

size_small: Tuple[float, float] = (6, 4)
size_medium: Tuple[float, float] = (8, 6)
size_large: Tuple[float, float] = (12, 8)
size_blog: Tuple[float, float] = (8, 6)
size_technical: Tuple[float, float] = (10, 8)
size_presentation: Tuple[float, float] = (10, 7.5)
dpi_screen: int = 100
dpi_web: int = 150
dpi_print: int = 300
class GridConfig(show_grid: bool = True, grid_alpha: float = 0.3, grid_linewidth: float = 0.5, spine_top: bool = False, spine_right: bool = False, spine_bottom: bool = True, spine_left: bool = True, spine_linewidth: float = 0.8, tick_major_width: float = 0.8, tick_minor_width: float = 0.4) None[source]

Bases: object

Grid and axis configuration.

show_grid

Whether to show grid lines

grid_alpha

Grid transparency

grid_linewidth

Grid line width

spine_top

Show top spine

spine_right

Show right spine

spine_bottom

Show bottom spine

spine_left

Show left spine

spine_linewidth

Spine line width

tick_major_width

Major tick width

tick_minor_width

Minor tick width

show_grid: bool = True
grid_alpha: float = 0.3
grid_linewidth: float = 0.5
spine_top: bool = False
spine_right: bool = False
spine_bottom: bool = True
spine_left: bool = True
spine_linewidth: float = 0.8
tick_major_width: float = 0.8
tick_minor_width: float = 0.4
class StyleManager(theme: Theme = Theme.DEFAULT, config_path: str | Path | None = None, custom_colors: Dict[str, str] | None = None, custom_fonts: Dict[str, Any] | None = None)[source]

Bases: object

Manages visualization styles and themes.

This class provides centralized style management for all visualizations, supporting multiple themes, custom configurations, and style inheritance.

Example

>>> style_mgr = StyleManager()
>>> style_mgr.set_theme(Theme.PRESENTATION)
>>> style_mgr.apply_style()
>>> # Create plots with consistent styling
>>> # Or with custom configuration
>>> style_mgr = StyleManager(config_path="custom_style.yaml")
>>> style_mgr.apply_style()
themes: Dict[Theme, Dict[str, Any]]
set_theme(theme: Theme) None[source]

Set the current theme.

Parameters:

theme (Theme) – Theme to activate

Return type:

None

get_theme_config(theme: Theme | None = None) Dict[str, Any][source]

Get configuration for a theme.

Parameters:

theme (Optional[Theme]) – Theme to get config for (defaults to current)

Return type:

Dict[str, Any]

Returns:

Theme configuration dictionary

get_colors() ColorPalette[source]

Get current color palette.

Return type:

ColorPalette

Returns:

Current theme’s color palette

get_fonts() FontConfig[source]

Get current font configuration.

Return type:

FontConfig

Returns:

Current theme’s font configuration

get_figure_config() FigureConfig[source]

Get current figure configuration.

Return type:

FigureConfig

Returns:

Current theme’s figure configuration

get_grid_config() GridConfig[source]

Get current grid configuration.

Return type:

GridConfig

Returns:

Current theme’s grid configuration

update_colors(updates: Dict[str, str]) None[source]

Update colors in current theme.

Parameters:

updates (Dict[str, str]) – Dictionary of color updates

Return type:

None

update_fonts(updates: Dict[str, Any]) None[source]

Update fonts in current theme.

Parameters:

updates (Dict[str, Any]) – Dictionary of font updates

Return type:

None

apply_style() None[source]

Apply current theme to matplotlib.

This updates matplotlib’s rcParams to match the current theme settings.

Return type:

None

get_figure_size(size_type: str = 'medium', orientation: str = 'landscape') Tuple[float, float][source]

Get figure size for a given type.

Parameters:
  • size_type (str) – Size type (small, medium, large, blog, technical, presentation)

  • orientation (str) – Figure orientation (landscape or portrait)

Return type:

Tuple[float, float]

Returns:

Tuple of (width, height) in inches

get_dpi(output_type: str = 'screen') int[source]

Get DPI for output type.

Parameters:

output_type (str) – Output type (screen, web, print)

Return type:

int

Returns:

DPI value

load_config(config_path: str | Path) None[source]

Load configuration from YAML file.

Parameters:

config_path (Union[str, Path]) – Path to YAML configuration file

Return type:

None

save_config(config_path: str | Path) None[source]

Save current configuration to YAML file.

Parameters:

config_path (Union[str, Path]) – Path to save YAML configuration

Return type:

None

create_style_sheet() Dict[str, Any][source]

Create matplotlib style sheet dictionary.

Return type:

Dict[str, Any]

Returns:

Style sheet dictionary compatible with matplotlib

inherit_from(parent_theme: Theme, modifications: Dict[str, Any]) Theme[source]

Create a new theme inheriting from a parent with modifications.

Parameters:
  • parent_theme (Theme) – Theme to inherit from

  • modifications (Dict[str, Any]) – Dictionary of modifications

Return type:

Theme

Returns:

New theme enum value

Module contents

Visualization infrastructure for professional report generation.

This package provides centralized styling and figure generation capabilities: - StyleManager: Manages themes, colors, fonts, and figure configurations - FigureFactory: Creates standardized plots with consistent styling

class StyleManager(theme: Theme = Theme.DEFAULT, config_path: str | Path | None = None, custom_colors: Dict[str, str] | None = None, custom_fonts: Dict[str, Any] | None = None)[source]

Bases: object

Manages visualization styles and themes.

This class provides centralized style management for all visualizations, supporting multiple themes, custom configurations, and style inheritance.

Example

>>> style_mgr = StyleManager()
>>> style_mgr.set_theme(Theme.PRESENTATION)
>>> style_mgr.apply_style()
>>> # Create plots with consistent styling
>>> # Or with custom configuration
>>> style_mgr = StyleManager(config_path="custom_style.yaml")
>>> style_mgr.apply_style()
themes: Dict[Theme, Dict[str, Any]]
set_theme(theme: Theme) None[source]

Set the current theme.

Parameters:

theme (Theme) – Theme to activate

Return type:

None

get_theme_config(theme: Theme | None = None) Dict[str, Any][source]

Get configuration for a theme.

Parameters:

theme (Optional[Theme]) – Theme to get config for (defaults to current)

Return type:

Dict[str, Any]

Returns:

Theme configuration dictionary

get_colors() ColorPalette[source]

Get current color palette.

Return type:

ColorPalette

Returns:

Current theme’s color palette

get_fonts() FontConfig[source]

Get current font configuration.

Return type:

FontConfig

Returns:

Current theme’s font configuration

get_figure_config() FigureConfig[source]

Get current figure configuration.

Return type:

FigureConfig

Returns:

Current theme’s figure configuration

get_grid_config() GridConfig[source]

Get current grid configuration.

Return type:

GridConfig

Returns:

Current theme’s grid configuration

update_colors(updates: Dict[str, str]) None[source]

Update colors in current theme.

Parameters:

updates (Dict[str, str]) – Dictionary of color updates

Return type:

None

update_fonts(updates: Dict[str, Any]) None[source]

Update fonts in current theme.

Parameters:

updates (Dict[str, Any]) – Dictionary of font updates

Return type:

None

apply_style() None[source]

Apply current theme to matplotlib.

This updates matplotlib’s rcParams to match the current theme settings.

Return type:

None

get_figure_size(size_type: str = 'medium', orientation: str = 'landscape') Tuple[float, float][source]

Get figure size for a given type.

Parameters:
  • size_type (str) – Size type (small, medium, large, blog, technical, presentation)

  • orientation (str) – Figure orientation (landscape or portrait)

Return type:

Tuple[float, float]

Returns:

Tuple of (width, height) in inches

get_dpi(output_type: str = 'screen') int[source]

Get DPI for output type.

Parameters:

output_type (str) – Output type (screen, web, print)

Return type:

int

Returns:

DPI value

load_config(config_path: str | Path) None[source]

Load configuration from YAML file.

Parameters:

config_path (Union[str, Path]) – Path to YAML configuration file

Return type:

None

save_config(config_path: str | Path) None[source]

Save current configuration to YAML file.

Parameters:

config_path (Union[str, Path]) – Path to save YAML configuration

Return type:

None

create_style_sheet() Dict[str, Any][source]

Create matplotlib style sheet dictionary.

Return type:

Dict[str, Any]

Returns:

Style sheet dictionary compatible with matplotlib

inherit_from(parent_theme: Theme, modifications: Dict[str, Any]) Theme[source]

Create a new theme inheriting from a parent with modifications.

Parameters:
  • parent_theme (Theme) – Theme to inherit from

  • modifications (Dict[str, Any]) – Dictionary of modifications

Return type:

Theme

Returns:

New theme enum value

class Theme(*values)[source]

Bases: Enum

Available visualization themes.

DEFAULT = 'default'
COLORBLIND = 'colorblind'
PRESENTATION = 'presentation'
MINIMAL = 'minimal'
PRINT = 'print'
class FigureFactory(style_manager: StyleManager | None = None, theme: Theme = Theme.DEFAULT, auto_apply: bool = True)[source]

Bases: object

Factory for creating standardized figures with consistent styling.

This class provides methods to create various types of plots with automatic application of themes, consistent formatting, and proper spacing.

Example

>>> factory = FigureFactory(theme=Theme.PRESENTATION)
>>> fig, ax = factory.create_line_plot(
...     x_data=[1, 2, 3, 4],
...     y_data=[10, 20, 15, 25],
...     title="Revenue Growth",
...     x_label="Quarter",
...     y_label="Revenue ($M)"
... )
>>> # Create multiple subplots
>>> fig, axes = factory.create_subplots(
...     rows=2, cols=2,
...     size_type="large",
...     subplot_titles=["Q1", "Q2", "Q3", "Q4"]
... )
create_figure(size_type: str = 'medium', orientation: str = 'landscape', dpi_type: str = 'screen', title: str | None = None) Tuple[Figure, Axes][source]

Create a basic figure with styling applied.

Parameters:
  • size_type (str) – Size preset (small, medium, large, blog, technical, presentation)

  • orientation (str) – Figure orientation (landscape or portrait)

  • dpi_type (str) – DPI type (screen, web, print)

  • title (Optional[str]) – Optional figure title

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_subplots(rows: int = 1, cols: int = 1, size_type: str = 'large', dpi_type: str = 'screen', title: str | None = None, subplot_titles: List[str] | None = None, **kwargs) Tuple[Figure, Axes | ndarray][source]

Create subplots with consistent styling.

Parameters:
  • rows (int) – Number of subplot rows

  • cols (int) – Number of subplot columns

  • size_type (str) – Size preset

  • dpi_type (str) – DPI type

  • title (Optional[str]) – Main figure title

  • subplot_titles (Optional[List[str]]) – Titles for each subplot

  • **kwargs – Additional arguments for plt.subplots

Return type:

Tuple[Figure, Union[Axes, ndarray]]

Returns:

Tuple of (figure, axes array)

create_line_plot(x_data: List | ndarray | Series, y_data: List | ndarray | Series | Dict[str, List | ndarray], title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', show_legend: bool = True, show_grid: bool = True, markers: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a line plot with automatic formatting.

Parameters:
  • x_data (Union[List, ndarray, Series]) – X-axis data

  • y_data (Union[List, ndarray, Series, Dict[str, Union[List, ndarray]]]) – Y-axis data (can be multiple series as dict)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Series labels for legend

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • show_legend (bool) – Whether to show legend

  • show_grid (bool) – Whether to show grid

  • markers (bool) – Whether to add markers to lines

  • **kwargs – Additional arguments for plot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_bar_plot(categories: List | ndarray, values: List | ndarray | Dict[str, List | ndarray], title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', orientation: str = 'vertical', show_values: bool = False, value_format: str = '.1f', **kwargs) Tuple[Figure, Axes][source]

Create a bar plot with automatic formatting.

Parameters:
  • categories (Union[List, ndarray]) – Category labels

  • values (Union[List, ndarray, Dict[str, Union[List, ndarray]]]) – Values to plot (can be multiple series as dict)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Series labels for legend

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • orientation (str) – Bar orientation (vertical or horizontal)

  • show_values (bool) – Whether to show value labels on bars

  • value_format (str) – Format string for value labels

  • **kwargs – Additional arguments for bar plot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_scatter_plot(x_data: List | ndarray, y_data: List | ndarray, title: str | None = None, x_label: str | None = None, y_label: str | None = None, size_type: str = 'medium', dpi_type: str = 'screen', colors: List | ndarray | None = None, sizes: List | ndarray | None = None, labels: List[str] | None = None, show_colorbar: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a scatter plot with automatic formatting.

Parameters:
  • x_data (Union[List, ndarray]) – X-axis data

  • y_data (Union[List, ndarray]) – Y-axis data

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • colors (Union[List, ndarray, None]) – Optional colors for points (for continuous coloring)

  • sizes (Union[List, ndarray, None]) – Optional sizes for points

  • labels (Optional[List[str]]) – Optional labels for points

  • show_colorbar (bool) – Whether to show colorbar when colors provided

  • **kwargs – Additional arguments for scatter

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_histogram(data: List | ndarray | Series, title: str | None = None, x_label: str | None = None, y_label: str = 'Frequency', bins: int | str = 'auto', size_type: str = 'medium', dpi_type: str = 'screen', show_statistics: bool = False, show_kde: bool = False, **kwargs) Tuple[Figure, Axes][source]

Create a histogram with automatic formatting.

Parameters:
  • data (Union[List, ndarray, Series]) – Data to plot

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (str) – Y-axis label

  • bins (Union[int, str]) – Number of bins or method

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • show_statistics (bool) – Whether to show mean/median lines

  • show_kde (bool) – Whether to overlay KDE

  • **kwargs – Additional arguments for hist

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_heatmap(data: ndarray | DataFrame, title: str | None = None, x_labels: List[str] | None = None, y_labels: List[str] | None = None, x_label: str | None = None, y_label: str | None = None, size_type: str = 'medium', dpi_type: str = 'screen', cmap: str = 'RdBu_r', show_values: bool = True, value_format: str = '.2f', **kwargs) Tuple[Figure, Axes][source]

Create a heatmap with automatic formatting.

Parameters:
  • data (Union[ndarray, DataFrame]) – 2D data array or DataFrame

  • title (Optional[str]) – Plot title

  • x_labels (Optional[List[str]]) – Labels for x-axis

  • y_labels (Optional[List[str]]) – Labels for y-axis

  • x_label (Optional[str]) – X-axis title

  • y_label (Optional[str]) – Y-axis title

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • cmap (str) – Colormap name

  • show_values (bool) – Whether to show values in cells

  • value_format (str) – Format string for cell values

  • **kwargs – Additional arguments for imshow

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

create_box_plot(data: List[List] | Dict[str, List] | DataFrame, title: str | None = None, x_label: str | None = None, y_label: str | None = None, labels: List[str] | None = None, size_type: str = 'medium', dpi_type: str = 'screen', orientation: str = 'vertical', show_means: bool = True, **kwargs) Tuple[Figure, Axes][source]

Create a box plot with automatic formatting.

Parameters:
  • data (Union[List[List], Dict[str, List], DataFrame]) – Data for box plot (list of lists, dict, or DataFrame)

  • title (Optional[str]) – Plot title

  • x_label (Optional[str]) – X-axis label

  • y_label (Optional[str]) – Y-axis label

  • labels (Optional[List[str]]) – Labels for each box

  • size_type (str) – Figure size preset

  • dpi_type (str) – DPI type

  • orientation (str) – Plot orientation (vertical or horizontal)

  • show_means (bool) – Whether to show mean markers

  • **kwargs – Additional arguments for boxplot

Return type:

Tuple[Figure, Axes]

Returns:

Tuple of (figure, axes)

format_axis_currency(ax: Axes, axis: str = 'y', abbreviate: bool = True, decimals: int = 0) None[source]

Format axis labels as currency.

Parameters:
  • ax (Axes) – Matplotlib axes

  • axis (str) – Which axis to format (x or y)

  • abbreviate (bool) – Whether to abbreviate large numbers

  • decimals (int) – Number of decimal places

Return type:

None

format_axis_percentage(ax: Axes, axis: str = 'y', decimals: int = 0) None[source]

Format axis labels as percentages.

Parameters:
  • ax (Axes) – Matplotlib axes

  • axis (str) – Which axis to format (x or y)

  • decimals (int) – Number of decimal places

Return type:

None

add_annotations(ax: Axes, x: float, y: float, text: str, arrow: bool = True, offset: Tuple[float, float] = (10, 10), **kwargs) None[source]

Add styled annotation to plot.

Parameters:
  • ax (Axes) – Matplotlib axes

  • x (float) – X coordinate

  • y (float) – Y coordinate

  • text (str) – Annotation text

  • arrow (bool) – Whether to show arrow

  • offset (Tuple[float, float]) – Text offset from point

  • **kwargs – Additional arguments for annotate

Return type:

None

save_figure(fig: Figure, filename: str, output_type: str = 'web', **kwargs) None[source]

Save figure with appropriate DPI settings.

Parameters:
  • fig (Figure) – Figure to save

  • filename (str) – Output filename

  • output_type (str) – Output type (screen, web, print)

  • **kwargs – Additional arguments for savefig

Return type:

None