Skip to content

Commit 3886637

Browse files
spec: add line-basic specification
Created from issue #162
1 parent 3a21de5 commit 3886637

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

specs/line-basic.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# line-basic: Basic Line Plot
2+
3+
A fundamental line plot for visualizing trends and continuous data over an ordered sequence. Ideal for time series, trend analysis, and any scenario where data points should be connected to show progression or change over time.
4+
5+
## Description
6+
7+
A basic line plot connects data points with a continuous line to reveal trends, patterns, and changes in data over a sequence. This is one of the most common visualization types, essential for time series analysis, tracking metrics over time, and showing how values evolve across ordered categories or indices.
8+
9+
## Data Requirements
10+
11+
| Column | Type | Required | Description |
12+
|--------|------|----------|-------------|
13+
| x | numeric/datetime | Yes | X-axis values representing the sequence (time, index, or ordered category) |
14+
| y | numeric | Yes | Y-axis values representing the measured quantity |
15+
16+
## Optional Parameters
17+
18+
| Parameter | Type | Default | Description |
19+
|-----------|------|---------|-------------|
20+
| figsize | tuple | (10, 6) | Figure size as (width, height) in inches |
21+
| linewidth | float | 2.0 | Width of the line in points |
22+
| color | string | "steelblue" | Line color |
23+
| alpha | float | 1.0 | Line transparency (0.0 to 1.0) |
24+
| marker | string | None | Marker style for data points (e.g., 'o', 's', '^') |
25+
| markersize | float | 6.0 | Size of markers if enabled |
26+
| title | string | "Line Plot" | Plot title |
27+
| xlabel | string | "X" | X-axis label |
28+
| ylabel | string | "Y" | Y-axis label |
29+
| linestyle | string | "-" | Line style ('-', '--', '-.', ':') |
30+
| grid | bool | True | Whether to show grid lines |
31+
32+
## Quality Criteria
33+
34+
- [ ] X and Y axes are clearly labeled with descriptive text
35+
- [ ] Line is clearly visible with appropriate width (2px or equivalent)
36+
- [ ] Grid lines are visible but subtle (alpha ≤ 0.3) for readability
37+
- [ ] No overlapping axis labels or tick marks
38+
- [ ] Data points are accurately connected in sequential order
39+
- [ ] Figure size is appropriate (10x6 inches or equivalent aspect ratio)
40+
- [ ] Title is present and descriptive
41+
- [ ] Line color provides good contrast against background
42+
- [ ] Type hints and input validation are present in implementation
43+
- [ ] Handles edge cases gracefully (empty data, single point, NaN values)
44+
45+
## Expected Output
46+
47+
A clean, professional line plot with a single continuous line connecting all data points in order. The plot should have:
48+
- A clear title at the top ("Line Plot" by default)
49+
- Labeled X and Y axes with appropriate tick marks
50+
- A subtle grid for easy value reading
51+
- Sufficient margins so no labels are cut off
52+
- A line width of 2px (or equivalent) for good visibility
53+
- Optional markers at data points for precise value identification
54+
55+
The overall appearance should be minimal and professional, suitable for reports, presentations, and dashboards.
56+
57+
## Tags
58+
59+
line, trend, time-series, basic, 2d, sequential
60+
61+
## Use Cases
62+
63+
- **Stock price tracking**: Visualizing daily closing prices of a stock over weeks or months to identify trends and patterns
64+
- **Temperature monitoring**: Plotting daily average temperatures over a year to see seasonal variations
65+
- **Website analytics**: Showing daily page views or unique visitors over time to track growth or detect anomalies
66+
- **Sales progression**: Displaying monthly or quarterly sales figures to identify business trends
67+
- **Performance metrics**: Tracking application response times or system CPU usage over time
68+
- **Scientific measurements**: Plotting experimental readings taken at regular intervals during an experiment
69+
70+
## Example Data
71+
72+
```python
73+
import pandas as pd
74+
75+
data = pd.DataFrame({
76+
'x': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
77+
'y': [2.3, 3.1, 4.5, 4.2, 5.8, 6.1, 5.9, 7.2, 8.1, 7.8]
78+
})
79+
80+
fig = create_plot(data, 'x', 'y')
81+
```
82+
83+
## Examples
84+
85+
### Example 1: Basic Usage
86+
```python
87+
import pandas as pd
88+
89+
data = pd.DataFrame({
90+
'x': [1, 2, 3, 4, 5],
91+
'y': [2, 4, 3, 5, 6]
92+
})
93+
fig = create_plot(data, 'x', 'y')
94+
```
95+
96+
### Example 2: Custom Styling with Markers
97+
```python
98+
fig = create_plot(
99+
data,
100+
'x',
101+
'y',
102+
linewidth=2.5,
103+
marker='o',
104+
markersize=8,
105+
title='Monthly Sales Trend',
106+
xlabel='Month',
107+
ylabel='Sales ($)',
108+
color='darkgreen'
109+
)
110+
```
111+
112+
### Example 3: Time Series Data
113+
```python
114+
import pandas as pd
115+
116+
data = pd.DataFrame({
117+
'date': pd.date_range('2024-01-01', periods=30, freq='D'),
118+
'value': [23, 25, 22, 28, 30, 29, 31, 33, 32, 35,
119+
34, 36, 38, 37, 40, 42, 41, 43, 45, 44,
120+
46, 48, 47, 50, 52, 51, 53, 55, 54, 56]
121+
})
122+
fig = create_plot(data, 'date', 'value', title='Daily Metrics')
123+
```
124+
125+
## Implementation Notes
126+
127+
- Sort data by x-axis values before plotting to ensure correct line connectivity
128+
- Handle missing/NaN values gracefully (skip or interpolate based on library capabilities)
129+
- Validate that x and y columns exist and contain appropriate data types
130+
- Use antialiasing for smooth line rendering where supported
131+
- Ensure consistent behavior across all 9 supported libraries

0 commit comments

Comments
 (0)