import matplotlib.pyplot as plt import time def plotVoltages(vList): if ~plt.fignum_exists(1): print("true") plt.ylabel("Voltage (V)") plt.xlabel("Cell Number") plt.bar(vList, [1,2,3,4]) plt.show() else: plt.clf() plt.draw() return x = [1, 2, 3, 4] plotVoltages(x) time.sleep(3) plt.clf() x = [4,3,2,1] plotVoltages(x)