matplotlib.artist.Artist.add_callback#

Artist.add_callback(func)[source]#

添加一个回调函数,当 Artist 的任何属性发生改变时都会调用该函数。

参数:
funccallable

回调函数。它必须具有以下签名:

def func(artist: Artist) -> Any

其中 artist 是调用方的 Artist。返回值可能存在但会被忽略。

返回:
int

与回调关联的观察者 ID。此 ID 可用于稍后通过 remove_callback 移除回调。

另请参阅

remove_callback