更新时间:2023-02-26 16:54:54
根据@ImportanceOfBeingErnest 的建议,需要更新坐标区限制.
As suggested by @ImportanceOfBeingErnest, the axes limits need to be updated.
以下代码应该可以解决您的问题:
The following code should solve your problem:
import matplotlib
matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
canvas = fig.canvas
class MyApp(App):
def build(self):
box = BoxLayout()
self.i = 0
self.line = [self.i]
box.add_widget(canvas)
plt.show()
Clock.schedule_interval(self.update, 1)
return box
def update(self, *args):
plt.plot(self.line, self.line)
self.i += 1
self.line.append(self.i)
canvas.draw_idle()
MyApp().run()