Skip to content

Commit f2f79bf

Browse files
spec: add bar-spine specification (#5266)
## New Specification: `bar-spine` Related to #5249 --- ### specification.md # bar-spine: Spine Plot for Two-Variable Proportions ## Description A spine plot (spineplot) is a stacked bar chart where bar widths are proportional to the marginal frequency of one categorical variable and the subdivisions within each bar show the conditional distribution of a second categorical variable. All bars are normalized to the same height (100%), so visual comparison focuses on how the conditional proportions shift across categories. It is a one-dimensional specialization of mosaic plots and excels at revealing associations between two categorical variables in contingency table data. ## Applications - Showing survival rates across passenger classes in the Titanic dataset - Visualizing disease prevalence across demographic age groups - Displaying customer churn rates segmented by subscription tier - Comparing pass/fail rates across different experimental test conditions ## Data - `x_category` (categorical) - Primary categorical variable that determines bar width (marginal frequency) - `fill_category` (categorical) - Secondary categorical variable shown as stacked segments within each bar - `count` (integer) - Frequency count for each combination of x_category and fill_category - Size: 3-8 x-categories, 2-5 fill categories for readability - Example: Titanic survival data with passenger class as x_category, survival status as fill_category, and passenger counts ## Notes - Bar width must be proportional to the marginal count of each x_category - Segments within each bar represent conditional proportions of fill_category (heights sum to 100%) - All bars share the same total height (normalized to 100%) - Bars should be adjacent with no gaps to emphasize the continuous proportion axis - Use distinct colors for each fill_category with a clear legend - X-axis labels should be centered under each variable-width bar - Consider adding percentage labels within segments when space permits - Complements the existing mosaic-categorical spec as a simpler 1D alternative --- **Next:** Add `approved` label to the issue to merge this PR. --- :robot: *[spec-create workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/24290842605)* Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 5f20d9f commit f2f79bf

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

plots/bar-spine/specification.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# bar-spine: Spine Plot for Two-Variable Proportions
2+
3+
## Description
4+
5+
A spine plot (spineplot) is a stacked bar chart where bar widths are proportional to the marginal frequency of one categorical variable and the subdivisions within each bar show the conditional distribution of a second categorical variable. All bars are normalized to the same height (100%), so visual comparison focuses on how the conditional proportions shift across categories. It is a one-dimensional specialization of mosaic plots and excels at revealing associations between two categorical variables in contingency table data.
6+
7+
## Applications
8+
9+
- Showing survival rates across passenger classes in the Titanic dataset
10+
- Visualizing disease prevalence across demographic age groups
11+
- Displaying customer churn rates segmented by subscription tier
12+
- Comparing pass/fail rates across different experimental test conditions
13+
14+
## Data
15+
16+
- `x_category` (categorical) - Primary categorical variable that determines bar width (marginal frequency)
17+
- `fill_category` (categorical) - Secondary categorical variable shown as stacked segments within each bar
18+
- `count` (integer) - Frequency count for each combination of x_category and fill_category
19+
- Size: 3-8 x-categories, 2-5 fill categories for readability
20+
- Example: Titanic survival data with passenger class as x_category, survival status as fill_category, and passenger counts
21+
22+
## Notes
23+
24+
- Bar width must be proportional to the marginal count of each x_category
25+
- Segments within each bar represent conditional proportions of fill_category (heights sum to 100%)
26+
- All bars share the same total height (normalized to 100%)
27+
- Bars should be adjacent with no gaps to emphasize the continuous proportion axis
28+
- Use distinct colors for each fill_category with a clear legend
29+
- X-axis labels should be centered under each variable-width bar
30+
- Consider adding percentage labels within segments when space permits
31+
- Complements the existing mosaic-categorical spec as a simpler 1D alternative

plots/bar-spine/specification.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Specification-level metadata for bar-spine
2+
# Auto-synced to PostgreSQL on push to main
3+
4+
spec_id: bar-spine
5+
title: Spine Plot for Two-Variable Proportions
6+
7+
# Specification tracking
8+
created: "2026-04-11T20:24:05Z"
9+
updated: null
10+
issue: 5249
11+
suggested: MarkusNeusinger
12+
13+
# Classification tags (applies to all library implementations)
14+
# See docs/reference/tagging-system.md for detailed guidelines
15+
tags:
16+
plot_type:
17+
- bar
18+
- spine
19+
data_type:
20+
- categorical
21+
- frequency
22+
domain:
23+
- general
24+
- statistics
25+
features:
26+
- stacked
27+
- proportional
28+
- comparison

0 commit comments

Comments
 (0)