您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

快速更新图中的单个点

快速更新图中的单个点

和往常一样

因此

import matplotlib.pyplot as plt
import numpy as np

class Test:
    def __init__(self):
        self.fig = plt.figure(1)
        # Axis with large plot
        self.ax_large = plt.subplot(121)
        self.ax_large.imshow(np.random.random((5000,5000)))
        # Follow the point
        self.ax = plt.subplot(122)
        self.ax.grid(True)

        # set some limits to the axes
        self.ax.set_xlim(-5,5)
        self.ax.set_ylim(-5,5)
        # Draw the canvas once
        self.fig.canvas.draw()
        # Store the background for later
        self.background = self.fig.canvas.copy_from_b@R_607_2419@(self.ax.b@R_607_2419@)
        # Now create some point
        self.point, = self.ax.plot(0,0, 'go')
        # Create callback to mouse movement
        self.cid = self.fig.canvas.callbacks.connect('motion_notify_event', 
                                                     self.callback)
        plt.show()

    def callback(self, event):
        if event.inaxes == self.ax:
            # Update point's location            
            self.point.set_data(event.xdata, event.ydata)
            # Restore the background
            self.fig.canvas.restore_region(self.background)
            # draw the point on the screen
            self.ax.draw_artist(self.point)
            # blit the axes
            self.fig.canvas.blit(self.ax.b@R_607_2419@)


tt = test()
其他 2022/1/1 18:39:48 有588人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶