Skip to content

Commit 9290b86

Browse files
authored
feat: enhance timeline and waterfall plots with additional documentation and features (#64)
1 parent 8992a63 commit 9290b86

File tree

5 files changed

+83
-1991
lines changed

5 files changed

+83
-1991
lines changed

.markdownlint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"MD033": { "allowed_elements": ["div"] },
3+
"MD013": { "line_length": 120 }
4+
}

docs/analysis_modules.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ social:
1111

1212
<div class="clear" markdown>
1313

14-
![Image title](../assets/images/analysis_modules/waterfall.svg){ align=right loading=lazy width="50%"}
14+
![Image title](assets/images/analysis_modules/waterfall.svg){ align=right loading=lazy width="50%"}
1515

1616
Waterfall plots are particularly good for showing how different things add or subtract from a starting number. For
1717
instance,
@@ -42,3 +42,53 @@ waterfall_plot(
4242
rot=0,
4343
)
4444
```
45+
46+
### Timeline Plot
47+
48+
<div class="clear" markdown>
49+
50+
![Image title](assets/images/analysis_modules/time_plot.svg){ align=right loading=lazy width="50%"}
51+
52+
Timeline plots are a fundamental tool for interpreting transactional data within a temporal context. By presenting data
53+
in a chronological sequence, these visualizations reveal patterns and trends that might otherwise remain hidden in raw
54+
numbers, making them essential for both historical analysis and forward-looking insights. They are particularly useful
55+
for:
56+
57+
- Tracking sales performance across different periods (e.g., daily, weekly, monthly)
58+
- Identifying seasonal patterns or promotional impacts on sales
59+
- Comparing the performance of different product categories or store locations over time
60+
- Visualizing customer behavior trends, such as purchase frequency or average transaction value
61+
62+
</div>
63+
64+
Example:
65+
66+
```python
67+
import numpy as np
68+
import pandas as pd
69+
70+
from pyretailscience.standard_graphs import time_plot
71+
72+
# Create a sample DataFrame with 3 groups
73+
rng = np.random.default_rng(42)
74+
df = pd.DataFrame(
75+
{
76+
"transaction_datetime": pd.concat([pd.Series(pd.date_range(start="2022-01-01", periods=200, freq="D"))] * 3),
77+
"total_price": np.concatenate([rng.integers(1, 1000, size=200) * multiplier for multiplier in range(1, 4)]),
78+
"group": ["Group A"] * 200 + ["Group B"] * 200 + ["Group C"] * 200,
79+
},
80+
)
81+
82+
time_plot(
83+
df,
84+
period="M",
85+
group_col="group",
86+
value_col="total_price",
87+
agg_func="sum",
88+
title="Monthly Sales by Customer Group",
89+
y_label="Sales",
90+
legend_title="Customer Group",
91+
source_text="Source: PyRetailScience - Sales FY2024",
92+
move_legend_outside=True,
93+
)
94+
```

docs/assets/images/analysis_modules/time_plot.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)