Skip to content

Commit cbe3997

Browse files
committed
MNT: teak examples a bit
1 parent 2c29af3 commit cbe3997

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

00-explore.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
import numpy as np
33
plt.ion()
44

5-
ev = None
5+
last_ev = None
66

77

88
def event_printer(event):
99
"""Helper function for exploring events.
1010
1111
Prints all public attributes +
1212
"""
13-
global ev
14-
ev = event
13+
# capture the last event
14+
global last_ev
15+
last_ev = event
1516
for k, v in sorted(vars(event).items()):
16-
print('{k}: {v!r}'.format(k=k, v=v))
17+
print(f'{k}: {v!r}')
1718
print('-'*25)
1819

20+
1921
th = np.linspace(0, 2*np.pi, 64)
2022
fig, ax = plt.subplots()
2123
ax.plot(th, np.sin(th), 'o-', picker=5)

02-event_filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ def on_key(self, event):
5151
# ask the GUI to re-draw the next time it can
5252
self.ln.figure.canvas.draw_idle()
5353

54+
5455
fig, ax = plt.subplots()
5556
ln, = ax.plot([], [], '-o')
5657
line_maker = LineMaker(ln)
5758

5859
# EXERCISE
59-
# - modify to remove the closest point on button == 3 or key == 'shift'
60+
# - modify to remove the closest point when key == 'shift'
6061
# - change the line width for [1-9]
6162
# - clear the line when event.key == 'escape'

pddc_helpers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from urllib.request import urlopen
21
import datetime
3-
import numpy as np
42
import pandas as pd
5-
import gzip
63
import os
74

5+
86
def aggregate_by_month(df, col='T'):
97
gb = df.groupby(('year', 'month'))['T'].describe().unstack()
108
new_index = [datetime.date(*m, *(15, )) for m in gb.index]

0 commit comments

Comments
 (0)