matplotlib.lines.VertexSelector#
- class matplotlib.lines.VertexSelector(line)[source]#
基类:
object
管理回调以维护
Line2D
的选定顶点列表。派生类应重写process_selected
方法来处理选定的点。这是一个用红色圆圈突出显示选定顶点的示例
import numpy as np import matplotlib.pyplot as plt import matplotlib.lines as lines class HighlightSelected(lines.VertexSelector): def __init__(self, line, fmt='ro', **kwargs): super().__init__(line) self.markers, = self.axes.plot([], [], fmt, **kwargs) def process_selected(self, ind, xs, ys): self.markers.set_data(xs, ys) self.canvas.draw() fig, ax = plt.subplots() x, y = np.random.rand(2, 30) line, = ax.plot(x, y, 'bs-', picker=5) selector = HighlightSelected(line) plt.show()
- property canvas#
- process_selected(ind, xs, ys)[source]#
process_selected
方法的默认“不做任何事”实现。- 参数:
- indint 列表
选定顶点的索引。
- xs, ys类数组
选定顶点的坐标。