本文簡要介紹 python 語言中 matplotlib.backend_bases.PickEvent
的用法。
-
基礎:
Event
一個選擇事件。
當用戶在畫布上選擇一個足夠靠近已通過
Artist.set_picker
選擇的藝術家的位置時,將觸發此事件。除了父類
Event
定義的屬性之外,PickEvent 還具有許多特殊屬性。例子
綁定一個函數
on_pick()
來選擇事件,打印所選擇的數據點的坐標:ax.plot(np.rand(100), 'o', picker=5) # 5 points tolerance def on_pick(event): line = event.artist xdata, ydata = line.get_data() ind = event.ind print(f'on pick line: {xdata[ind]:.3f}, {ydata[ind]:.3f}') cid = fig.canvas.mpl_connect('pick_event', on_pick)
- 屬性:
- mouseevent
MouseEvent
-
生成選擇的鼠標事件。
- artist
Artist
-
被選中的藝術家。請注意,默認情況下藝術家是不可挑選的(請參閱
Artist.set_picker
)。 - other
-
根據拾取對象的類型,可能會出現其他屬性;例如,
Line2D
選擇可能定義與PatchCollection
選擇不同的額外屬性。
- mouseevent
用法
class matplotlib.backend_bases.PickEvent(name, canvas, mouseevent, artist, guiEvent=None, **kwargs)
相關用法
- Python matplotlib PolyQuadMesh.set_hatch用法及代碼示例
- Python matplotlib PolyCollection.sticky_edges用法及代碼示例
- Python matplotlib PathCollection.set_hatch用法及代碼示例
- Python matplotlib PatchCollection.sticky_edges用法及代碼示例
- Python matplotlib PolyCollection.set_hatch用法及代碼示例
- Python matplotlib PatchCollection.set_hatch用法及代碼示例
- Python matplotlib PdfPages用法及代碼示例
- Python matplotlib PolyQuadMesh用法及代碼示例
- Python matplotlib PathCollection.legend_elements用法及代碼示例
- Python matplotlib PsfontsMap用法及代碼示例
- Python matplotlib PolyQuadMesh.sticky_edges用法及代碼示例
- Python matplotlib PathCollection.sticky_edges用法及代碼示例
- Python matplotlib Patch.set_hatch用法及代碼示例
- Python matplotlib Patch.contains_point用法及代碼示例
- Python matplotlib axvspan用法及代碼示例
- Python matplotlib Axes.get_legend_handles_labels用法及代碼示例
- Python matplotlib AbstractMovieWriter用法及代碼示例
- Python matplotlib triplot用法及代碼示例
- Python matplotlib StarPolygonCollection.set_hatch用法及代碼示例
- Python matplotlib Axes.hist用法及代碼示例
- Python matplotlib boxplot用法及代碼示例
- Python matplotlib subplots用法及代碼示例
- Python matplotlib InsetPosition用法及代碼示例
- Python matplotlib ToolManager.toolmanager_disconnect用法及代碼示例
- Python matplotlib Figure.set_size_inches用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.backend_bases.PickEvent。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。