vivainsights.create_bubble¶
Create a bubble chart visualization of two metrics by organizational group.
The function create_bubble creates a bubble visualization and summary table for a given metric and grouping variable in a dataset.
- vivainsights.create_bubble.create_bubble(data, metric_x, metric_y, hrvar='Organization', mingroup=5, return_type='plot', bubble_size=(1, 100), figsize=None)[source]¶
Create a bubble plot of two metrics by organizational group.
Metrics are first aggregated per person, then per HR variable group. Bubble size represents the number of employees in each group.
- Parameters:
data (pandas.DataFrame) – Person query data.
metric_x (str) – Column name for the x-axis metric.
metric_y (str) – Column name for the y-axis metric.
hrvar (str, optional) – Organizational attribute for grouping. Defaults to
"Organization".mingroup (int, optional) – Minimum group size. Groups below this are excluded. Defaults to 5.
return_type (str, optional) –
"plot"(default) returns a bubble chart;"table"returns a summary DataFrame.bubble_size (tuple, optional) –
(min_size, max_size)range for bubble scaling. Defaults to(1, 100).figsize (tuple, optional) – Figure size as
(width, height)in inches. Defaults to(8, 6).
- Returns:
Bubble chart or summary table depending on
return_type.- Return type:
matplotlib.figure.Figure or pandas.DataFrame
Examples
Return a bubble plot (default):
>>> import vivainsights as vi >>> pq_data = vi.load_pq_data() >>> vi.create_bubble( ... data=pq_data, ... metric_x="Collaboration_hours", ... metric_y="Multitasking_hours", ... hrvar="Organization", ... )
Return a summary table:
>>> vi.create_bubble( ... data=pq_data, ... metric_x="Collaboration_hours", ... metric_y="Multitasking_hours", ... hrvar="LevelDesignation", ... return_type="table", ... )
Customize bubble size range, minimum group size, and figure size:
>>> vi.create_bubble( ... data=pq_data, ... metric_x="Collaboration_hours", ... metric_y="Multitasking_hours", ... hrvar="Organization", ... bubble_size=(5, 200), ... mingroup=10, ... figsize=(12, 8), ... )