From d0f64e2041728634b185fcd46497ec93973c2057 Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Mon, 20 Dec 2021 17:59:39 +0000 Subject: specificPoints.py: Enable live plot updates. * fullswof-utils/specificPoints.py: Add on_press() function. --- fullswof-utils/specificPoints.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'fullswof-utils') diff --git a/fullswof-utils/specificPoints.py b/fullswof-utils/specificPoints.py index 03bdfe7..0f27911 100755 --- a/fullswof-utils/specificPoints.py +++ b/fullswof-utils/specificPoints.py @@ -3,17 +3,32 @@ 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) - fig, ax = plt.subplots() - plt.plot(t,h, label='elevation') plt.xlabel('time / s') plt.ylabel('water height / m') - ax.yaxis.set_minor_locator(MultipleLocator(0.2)) - plt.grid(True, which='minor') + plt.plot(t,h, 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, label='elevation') + fig.canvas.draw() + fig.canvas.mpl_connect('key_press_event', on_press) + plt.show() if os.fork(): -- cgit