-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path02-custom_plotting.py
More file actions
33 lines (25 loc) · 954 Bytes
/
Copy path02-custom_plotting.py
File metadata and controls
33 lines (25 loc) · 954 Bytes
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
29
30
31
32
33
import matplotlib.pyplot as plt
from w_helpers import load_data, aggregate_by_month
plt.ion()
temperature = load_data('mdw')
temperature_monthly = aggregate_by_month(temperature)
fig, ax = plt.subplots()
def plot_aggregated_errorbar(ax, gb, label, picker=None, **kwargs):
kwargs.setdefault('capsize', 3)
kwargs.setdefault('markersize', 5)
kwargs.setdefault('marker', 'o')
eb = ax.errorbar(gb.index, 'mean',
yerr='std',
data=gb,
label=label,
picker=picker,
**kwargs)
fill = ax.fill_between(gb.index, 'min', 'max', alpha=.5,
data=gb, color=eb[0].get_color())
ax.legend()
ax.figure.canvas.draw_idle()
return eb, fill
arts = plot_aggregated_errorbar(ax, temperature_monthly, 'temperature')
# EXERCISE (10 minutes)
# - make the shaded area configurable
# - make center line configurable