The import matplotlib. Pyplot as PLT
The import matplotlib. Font_manager as font_manager
The import numpy as np
The import CSV
F=open (" C:/Users/jyz_1/Desktop/datamodi CSV ", "r")
Y_list=[]
T0=eval (input (" time interval: "))
POINTS=10 + 1
* t0Y_list=[0] * POINTS
Indx=0
FIG, ax=PLT. Subplots ()
Ax. Set_ylim (40 [0])
Ax. Set_xlim ([0, POINTS])
Ax. Set_autoscale_on (False)
Ax. Set_xticks (range (0, 10 * t0, t0))
Ax. Set_yticks (range (0,40,5))
Ax. The grid (True)
Line_y,=ax. The plot (range (POINTS), y_list, label='y output, color=' cornflowerblue ')
Ax. Legend (loc='upper center', ncol=4, prop=font_manager. FontProperties (size=10))
Def y_output (ax) :
Global indx, y_list line_y
If indx==20:
Indx=0
Indx +=1
F=open (" C:/Users/jyz_1/Desktop/datamodi CSV ", "r")
Y_list=[]
Reader=CSV. Reader (f)
For low in reader:
For y in low:
Y_list=np. Append (y_list, eval (y))
Line_y. Set_ydata (y_list)
Ax. Draw_artist (line_y)
Ax. Figure. Canvas. The draw ()
The timer=FIG. Canvas. New_timer (interval=100)
The timer. Add_callback (y_output, ax)
The timer. The start ()
PLT. The show ()
Error:
The Exception in Tkinter callback
Traceback (the most recent call last) :
The File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ tkinter \ set py", line 1883, in __call__
Return the self. Func (* args)
The File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ tkinter \ set py", line 804, in callit
Func (* args)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ backends \ _backend_tk py", line 114, in _on_timer
TimerBase. _on_timer (self)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ backend_bases py", line 1187, in _on_timer
Ret=func (* args, * * kwargs)
The File "C: \ Users \ jyz_1 \ Desktop \ sensor_ver1 py", line 32, in y_output
Ax. Draw_artist (line_y)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ axes \ _base py", line 2644, in draw_artist
A. d. raw (self) figure) _cachedRenderer)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ artist py", line, 38 in draw_wrapper
Return the draw (artist, the renderer, * args, * * kwargs)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ lines py", line 759, in the draw
Self. Recache ()
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ matplotlib \ lines py", line 679, in recache
Self. _xy=np. Column_stack (np) broadcast_arrays (x, y)). Astype (float)
The File "& lt; __array_function__ internals>" , line 5, in broadcast_arrays
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ numpy \ lib \ stride_tricks py", line 264, in broadcast_arrays
Shape=_broadcast_shape (* args)
File "C: \ Users \ jyz_1 \ AppData \ Local \ designed \ Python \ Python38-32 \ lib \ site - packages \ numpy \ lib \ stride_tricks py", line 191, in _broadcast_shape
B=np. Broadcast (* args: [32])
ValueError: shape mismatch: objects always be broadcast to a single shape