-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting.py
28 lines (25 loc) · 878 Bytes
/
plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import plotly.graph_objects as go
import pandas as pd
import sitcen.charts as sc
COLOURS = {
2022 : sc.change_opacity('#000000', 0.3),
2023 : '#088486',
2024 : '#ed3f23',
}
def cum_scatter(data, col, **kwargs):
fig = go.Figure()
data_copy = data.copy()
data_copy = data_copy.filter_data(**kwargs)
for year in list(data_copy.data['year'].unique()):
subset = data_copy.data[data_copy.data['year'] == year]
subset = subset.sort_values('timestamp', ascending=True)
subset[col] = pd.to_numeric(subset[col])
subset[f'{col}_cumsum'] = subset[col].cumsum()
fig.add_trace(go.Scatter(
x = subset['standardised_date'],
y = subset[f'{col}_cumsum'],
name = str(year),
line_color = COLOURS.get(year, '#000000')
))
fig = sc.add_side_label(fig)
return fig