I am trying to write some code that plots a graph whilst going through a for loop and updates the graph with each iteration using matplotlib. I am plotting the voltage_trim[0:index] in order to avoid the problem of having two lists of different size but I still get an error that x and y must have same first dimensions. Does anyone know how one plots two lists of different size to have an updating real time graph?
voltage_trim = range(16)
current_meas = []
fig1 = plt.figure()
for index, value in enumerate(voltage_trim):
current_meas.append(random.randint(0,10))
plt.cla()
plt.plot(voltage_trim[:index], current_meas )