Skip to content

Commit 66515b1

Browse files
spec: add bar-basic specification
Created from issue #117
1 parent 76aece5 commit 66515b1

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

specs/bar-basic.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# bar-basic: Basic Bar Chart
2+
3+
A fundamental vertical bar chart that visualizes categorical data with numeric values, ideal for comparing quantities across discrete categories.
4+
5+
## Description
6+
7+
A basic bar chart displays rectangular bars with heights proportional to the values they represent. Each bar corresponds to a category, with the bar height indicating the numeric value for that category. This chart type is essential for comparing values across distinct groups and is one of the most widely used visualization types for categorical comparisons.
8+
9+
## Data Requirements
10+
11+
| Column | Type | Required | Description |
12+
|--------|------|----------|-------------|
13+
| category | string | Yes | Category labels for the x-axis (e.g., product names, regions) |
14+
| value | numeric | Yes | Numeric values determining bar heights |
15+
16+
## Optional Parameters
17+
18+
| Parameter | Type | Default | Description |
19+
|-----------|------|---------|-------------|
20+
| figsize | tuple | (10, 6) | Figure size as (width, height) |
21+
| color | string | "steelblue" | Bar fill color |
22+
| edgecolor | string | "black" | Bar edge color |
23+
| alpha | float | 0.8 | Transparency level for bars |
24+
| title | string | None | Plot title |
25+
| xlabel | string | None | X-axis label (defaults to column name) |
26+
| ylabel | string | None | Y-axis label (defaults to column name) |
27+
| rotation | int | 0 | Rotation angle for x-axis labels |
28+
29+
## Quality Criteria
30+
31+
- [ ] X-axis displays category labels clearly without overlap
32+
- [ ] Y-axis shows numeric scale with appropriate tick marks
33+
- [ ] Both axes are labeled (custom or column names)
34+
- [ ] Grid lines are visible but subtle (alpha ≤ 0.3) on y-axis only
35+
- [ ] Bars have consistent width and spacing
36+
- [ ] Bar colors are distinguishable from background
37+
- [ ] Title is present when specified
38+
- [ ] No visual clutter or overlapping elements
39+
- [ ] Y-axis starts at zero to avoid misleading representation
40+
41+
## Expected Output
42+
43+
A clean vertical bar chart where each category is represented by a rectangular bar. The bars should be evenly spaced along the x-axis with category labels beneath them. The y-axis should display a numeric scale starting from zero with subtle horizontal grid lines for easy value reading. The chart should have a professional appearance with proper margins, readable fonts, and a balanced layout. When there are many categories, the x-axis labels should be rotated to prevent overlap.
44+
45+
## Example Data
46+
47+
```python
48+
import pandas as pd
49+
50+
data = pd.DataFrame({
51+
'category': ['Product A', 'Product B', 'Product C', 'Product D', 'Product E'],
52+
'value': [45, 78, 52, 91, 63]
53+
})
54+
55+
fig = create_plot(data, 'category', 'value', title='Sales by Product')
56+
```
57+
58+
## Tags
59+
60+
bar, comparison, categorical, basic, 1d
61+
62+
## Use Cases
63+
64+
- Comparing sales figures across different product categories in retail analytics
65+
- Displaying survey response counts for multiple-choice questions
66+
- Showing population counts across different age groups or regions
67+
- Visualizing budget allocation across departments in business reporting
68+
- Presenting test scores or performance metrics across different groups
69+
- Comparing website traffic or user engagement metrics across pages
70+
71+
## Implementation Notes
72+
73+
- Handle long category labels gracefully (rotation or truncation)
74+
- Validate that category column contains appropriate categorical data
75+
- Ensure value column is numeric and handle missing values
76+
- Y-axis should always start at zero for accurate visual comparison
77+
- Bar width should be proportional to available space

0 commit comments

Comments
 (0)