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
34
35
36
37
38
39
|
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
from matplotlib.ticker import MultipleLocator
def detach_display():
fig, ax = plt.subplots()
t, x, y, h, u, v = np.loadtxt(
'hu_specific_points.dat', delimiter='\t', unpack=True)
plt.xlabel('time / s')
plt.ylabel('water height / m')
plt.plot(t,h, color='tab:cyan', label='elevation')
#ax.yaxis.set_minor_locator(MultipleLocator(200))
#plt.grid(True, which='minor')
def on_press(event):
#print('press', event.key)
#sys.stdout.flush()
if event.key == 'x':
plt.clf()
t, x, y, h, u, v = np.loadtxt(
'hu_specific_points.dat', delimiter='\t', unpack=True)
plt.xlabel('time / s')
plt.ylabel('water height / m')
plt.plot(t,h, color='tab:cyan', label='elevation')
fig.canvas.draw()
fig.canvas.mpl_connect('key_press_event', on_press)
plt.show()
if os.fork():
# parent
pass
else:
# child
detach_display()
|