From 3f45d7dc61447cb1ca993adce34b92542ff0780f Mon Sep 17 00:00:00 2001 From: tillraab Date: Wed, 11 Sep 2019 14:26:38 +0200 Subject: [PATCH] bf --- electrode_check.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/electrode_check.py b/electrode_check.py index ff8e5ca..e7c457f 100644 --- a/electrode_check.py +++ b/electrode_check.py @@ -28,7 +28,6 @@ class plot(): self.channel_handle = [] self.fig = plt.figure(figsize=(20 / 2.54, 12 / 2.54), facecolor='white') - self.fig.canvas.mpl_connect('key_press_event', self.keypress) self.axs = [] plt.show(block=False) @@ -49,16 +48,6 @@ class plot(): self.axs.append(ax) gs.update(left=0.05, bottom=0.05, top=1, right=1, hspace=0, wspace=0) - def keypress(self, event): - if event.key == 'v': - yrange = np.abs(np.diff(self.axs[0].get_ylim())) - for ax in self.axs: - ax.set_ylim(-(yrange / 2) * (2/3), (yrange / 2) * (2/3) ) - if event.key == 'V': - yrange = np.abs(np.diff(self.axs[0].get_ylim())) - for ax in self.axs: - ax.set_ylim(-(yrange / 2) * (3/2), (yrange / 2) * (3/2) ) - print('v pressed') def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin): @@ -371,15 +360,23 @@ def main(): power_channel = int(np.argmax(channel_std)) if init_fig == True: + yspan = (np.min(channel_std[power_channel]), np.max(channel_std[power_channel])) + ylim = (yspan[0] - np.abs(np.diff(yspan)) * 0.2, yspan[1] + np.abs(np.diff(yspan)) * 0.2) + for ch in channel_array: h, = Plot.axs[ch].plot(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch], color='k') + Plot.axs[ch].set_ylim(ylim) Plot.channel_handle.append(h) + Plot.fig.canvas.draw() + init_fig = False else: + yspan = (np.min(channel_std[power_channel]), np.max(channel_std[power_channel])) + ylim = (yspan[0] - np.abs(np.diff(yspan)) * 0.2, yspan[1] + np.abs(np.diff(yspan)) * 0.2) for ch in channel_array: Plot.channel_handle[ch].set_data(np.arange(250)[:len(channel_data[ch])] / rate, channel_data[ch]) - + Plot.axs[ch].set_ylim(ylim) Plot.fig.canvas.draw() if index == -1: