matplotlib.lines.VertexSelector class in Python Last Updated : 20 Aug, 2021 Comments Improve Suggest changes Like Article Like Report The matplotlib.lines.VertexSelector class belongs to the matplotlib.lines module. The matplotlib.lines module contains all the 2D line class that can be drawn with a variety of line styles, markers, and colors. matplotlib.lines.VertexSelector class is used to for managing the callbacks that maintain a list of selected vertices for matplotlib.lines.Line2D. The process_selected() function gets overridden by the derived classes for the picks. Syntax: class matplotlib.lines.VertexSelector(line)Parameter: lines: These represent the lines that are defined for the plotting. Methods of the class: onpick(self, event): The selected set of indices gets updated when the line is picked using this method.process_selected(self, ind, xs, ys): By default it does the implementation of "do nothing" of the process_selected() method. The 'ind' represents the indices of the selected vertices whereas 'xs' and 'ys' are the coordinates of the selected vertices. Example #1: Python3 import numpy as np import matplotlib.pyplot as plt import matplotlib.lines as lines # class for highlighting selected area class Highlighter(lines.VertexSelector): # constructor for the highlighter class def __init__(self, line, fmt ='ro', **kwargs): lines.VertexSelector.__init__(self, line) self.markers, = self.axes.plot([], [], fmt, **kwargs) # helper function process selected area and plot graph accordingly def process_selected(self, ind, xs, ys): self.markers.set_data(xs, ys) self.canvas.draw() figure, ax = plt.subplots() x_axis, y_axis = np.random.rand(2, 30) line, = ax.plot(x_axis, y_axis, 'bs-', picker = 5) selector = Highlighter(line) plt.show() Output: Example 2: Python3 import matplotlib.pyplot as plt import matplotlib.lines as lines from matplotlib.collections import PathCollection lines.VertexSelector # class for plot clicked area class dragged_lines: # constructor for the dragged_lines class def __init__(self, ax): self.ax = ax self.c = ax.get_figure().canvas self.line = lines.Line2D(x, y, picker = 5, marker ='o', markerfacecolor ='g', color ='y') self.ax.add_line(self.line) self.c.draw_idle() self.sid = self.c.mpl_connect('pick_event', self.lineclicker) def lineclicker(self, event): if event.artist: print("line selected ", event.artist) self.follower = self.c.mpl_connect("motion_notify_event", self.mouse_follower) self.releaser = self.c.mpl_connect("button_press_event", self.release_after_click) def mouse_follower(self, event): self.line.set_data([event.xdata, event.ydata]) self.c.draw_idle() def release_after_click(self, event): data = self.line.get_data() print(data) self.c.mpl_disconnect(self.releaser) self.c.mpl_disconnect(self.follower) figure = plt.figure() axes = figure.add_subplot(111) x_axis, y_axis = [2, 4, 5, 7], [8, 6, 12, 9] axes.plot(x_axis, y_axis) Vline = dragged_lines(axes) plt.show() Output: Comment More infoAdvertise with us Next Article matplotlib.lines.VertexSelector class in Python R RajuKumar19 Follow Improve Article Tags : Python Write From Home Python-matplotlib Practice Tags : python Similar Reads Plot a Vertical line in Matplotlib Plotting vertical lines is a technique in data visualization which is used to highlight specific data points, thresholds or regions on a graph. Whether we're marking key values, dividing data into segment, vertical lines can make our charts more informative. In this article, we'll see different meth 3 min read Line chart in Matplotlib - Python Matplotlib is a data visualization library in Python. The pyplot, a sublibrary of Matplotlib, is a collection of functions that helps in creating a variety of charts. Line charts are used to represent the relation between two data X and Y on a different axis. In this article, we will learn about lin 6 min read Matplotlib.axes.Axes.get_lines() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.set_figure() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.tricontour() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.scatter() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 4 min read matplotlib.axes.Axes.vlines() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.add_line() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.get_visible() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.artist.Artist.set_visible() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist. matplotlib.artist.Artist.set_visible() method The se 1 min read Like