In this article we will see how we can set a custom cursor to the line of line graph in the PyQtGraph module. PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. Its primary goals are to provide fast, interactive graphics for displaying data (plots, video, etc.) A line chart or line plot or line graph or curve chart is a type of chart that displays information as a series of data points called ‘markers’ connected by straight line segments. It is a basic type of chart common in many fields. Line graph is created with the help of plot class in PyQtGraph. Cursor is an indicator used to show the current position for user interaction on a computer monitor or other display device that will respond to input from a text input or pointing device. The mouse cursor is also called a pointer, owing to its resemblance in usage to a pointing stick.
We can create a plot window and create lines on it with the help of commands given below
# creating a pyqtgraph plot window plt = pg.plot() # ploting line in green color # with dot symbol as x, not a mandatory field line = plt.plot(x, y, pen='g', symbol='x', symbolPen='g', symbolBrush=0.2, name='green')
In order to do this we use setCursor method with the line object
Syntax : line.setCursor(cursor)
Argument : It takes QCursor object as argument
Return : It returns None
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- PyQtGraph - Getting Cursor of Line in Line Graph
- PyQtGraph – Setting Cursor of Bar Graph
- PyQtGraph – Setting Cursor to Scatter Plot Graph
- PyQtGraph - Setting Symbol of Line in Line Graph
- PyQtGraph - Setting Shadow Pen of Line in Line Graph
- PyQtGraph - Setting Pen of Line in Line Graph
- PyQtGraph - Setting Alpha Value of Line in Line Graph
- PyQtGraph - Setting Symbol Pen of Line in Line Graph
- PyQtGraph - Setting Symbol Size of Line in Line Graph
- PyQtGraph - Setting Symbol Brush of Line in Line Graph
- PyQtGraph - Setting Increased Inclination Angle of Line in Line Graph
- PyQtGraph - Setting Scale Factor of Line in Line Graph
- PyQtGraph - Setting X and Y Co-ordinates of Line in Line Graph
- PyQtGraph - Setting Starting Co-ordinates of Line in Line Graph
- PyQtGraph – Setting Custom Cursor for Image View
- PyQtGraph – Getting Cursor of Bar Graph
- PyQtGraph – Removing Cursor of Scatter Plot Graph
- PyQtGraph – Checking if Cursor is on Scatter Plot Graph
- PyQtGraph – Getting Cursor to Scatter Plot Graph
- PyQtGraph - Clearing the Line in Line Graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.