Вы, вероятно, хотите позвонить plt.ioff()
до plt.show()
.
В целом, лучше работать полностью внутри цикла событий, как показано ниже.
import pyfirmata
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
board = pyfirmata.Arduino('COM8')
iter8 = pyfirmata.util.Iterator(board)
iter8.start()
LED = board.get_pin('d:13:o')
ldr=board.get_pin('a:0:o')
val=0
converted=1023
converted2=5.0/1023.0
s=[]
i=0
fig, ax = plt.subplots()
line,= ax.plot([],[])
def update(i):
val=ldr.read()
print(val * converted * converted2)
s.append(val)
line.set_data(range(len(s)), s)
ax.autoscale()
ax.relim()
ax.autoscale_view()
FuncAnimation(fig, update, frames=50, repeat=False)
plt.show()