Python implements the method of drawing a straight line cursor between two coordinate axes in matplotlib
This example describes how to draw a straight line cursor between two coordinate axes in matplotlib using Python. Share it with you for your reference. The details are as follows:
Let's take a look at the examples and effects below.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#-*-Coding: UTF-8 -*- From matplotlib. widgets import MultiCursor From pylab import figure, show, np T = np. arange (0.0, 2.0, 0.01) S1 = np. sin (2 * np. pi * t) S2 = np. sin (4 * np. pi * t) Fig = figure () Ax1 = fig. add_subplot (211) Ax1.plot (t, s1) Ax2 = fig. add_subplot (212, sharex = ax1) Ax2.plot (t, s2) Multi = MultiCursor (fig. canvas, (ax1, ax2), color = 'R', lw = 1) Show () |
The following figure shows the graphic effect. As the cursor moves, a vertical line will be drawn between the two images.
This function is sometimes useful.
I hope this article will help you with Python programming.