@@ -11,7 +11,7 @@ social:
11
11
12
12
<div class =" clear " markdown >
13
13
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%"}
15
15
16
16
Waterfall plots are particularly good for showing how different things add or subtract from a starting number. For
17
17
instance,
@@ -42,3 +42,53 @@ waterfall_plot(
42
42
rot = 0 ,
43
43
)
44
44
```
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
+ ```
0 commit comments