#!/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()