pyqtgraph | Fast data visualization and GUI tools | Data Visualization library

 by   pyqtgraph Python Version: 0.13.7 License: Non-SPDX

kandi X-RAY | pyqtgraph Summary

kandi X-RAY | pyqtgraph Summary

pyqtgraph is a Python library typically used in Analytics, Data Visualization applications. pyqtgraph has no bugs, it has no vulnerabilities, it has build file available and it has high support. However pyqtgraph has a Non-SPDX License. You can install using 'pip install pyqtgraph' or download it from GitHub, PyPI.

[Language grade: Python] A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6. Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill. PyQtGraph is intended for use in mathematics / scientific / engineering applications. Despite being written entirely in python, the library is fast due to its heavy leverage of numpy for number crunching, Qt’s GraphicsView framework for 2D display, and OpenGL for 3D display.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pyqtgraph has a highly active ecosystem.
              It has 3280 star(s) with 1009 fork(s). There are 153 watchers for this library.
              There were 4 major release(s) in the last 6 months.
              There are 316 open issues and 847 have been closed. On average issues are closed in 213 days. There are 35 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of pyqtgraph is 0.13.7

            kandi-Quality Quality

              pyqtgraph has 0 bugs and 0 code smells.

            kandi-Security Security

              pyqtgraph has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pyqtgraph code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pyqtgraph has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              pyqtgraph releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are available. Examples and code snippets are not available.
              pyqtgraph saves you 23446 person hours of effort in developing the same functionality from scratch.
              It has 55047 lines of code, 4066 functions and 448 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pyqtgraph and discovered the below as its top functions. This is intended to give you an instant insight into pyqtgraph implemented functionality, and help decide if they suit your requirements.
            • Return an isosurface .
            • Generate draw specifications for this map .
            • Initialize shader programs .
            • Create an ARGB image from data .
            • Generate an Isocurve .
            • Generates a SVG for an item .
            • Handle incoming request .
            • Return the display dataset .
            • Set the image .
            • Convert array to QPath .
            Get all kandi verified functions for this library.

            pyqtgraph Key Features

            No Key Features are available at this moment for pyqtgraph.

            pyqtgraph Examples and Code Snippets

            How to solve the self-crash problem of running multiple pyqt or pyqtgraph drawing components?
            Pythondot img1Lines of Code : 311dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                    self.plots = [
                        PlotShow(...),
                        PlotShow(...),
                        PlotShow(...),
                        # ...
                    ]
            
            #import ble
            from PyQt5 import QtCore, QtWidgets
            import pyqtgraph as pg   # pg.Plot
            Plot line over pyqtgraph.ImageView()
            Pythondot img2Lines of Code : 78dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # -*- coding: utf-8 -*-
            """
            This example demonstrates the use of ImageView with 3-color image stacks.
            ImageView is a high-level widget for displaying and analyzing 2D and 3D data.
            ImageView provides:
            
              1. A zoomable region (ViewBox) for d
            pyqtgraph stacked bar graph
            Pythondot img3Lines of Code : 27dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pandas as pd
            import pyqtgraph as pg
            from pyqtgraph.Qt import QtGui
            import numpy as np
            from matplotlib import cm
            
            
            df = pd.DataFrame({'x': [1, 2, 3, 4],
                               'y1': [10, 20, 10, 30],
                               'y2': [20, 25, 15,
            Antialiasing images in pyqtgraph ImageView
            Pythondot img4Lines of Code : 6dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            class MyImageWidget(pg.ImageView):
                def __init__(self, parent=None):
                    # ...
                    self.blurEffect = QGraphicsBlurEffect(blurRadius=1.1)
                    self.imageItem.setGraphicsEffect(self.blurEffect)
            
            text in axes pyqtgraph
            Pythondot img5Lines of Code : 71dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import sys
            from math import sin
            from threading import Thread
            from time import sleep
            
            from PyQt5.QtCore import pyqtSignal, QPointF
            from PyQt5.QtWidgets import QApplication
            import pyqtgraph as pg
            
            
            class MovingLabelPlot(pg.PlotDataItem):
               
            pyqtgraph: completely clear PlotWidget
            Pythondot img6Lines of Code : 11dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for plot_item in [legend, p1, p2, p3]:
                plot_item.clear()
            
            active_plot_items = [legend, p1, p2, p3]
            
            def clear_plot_items():
                for plot_item in active_plot_items:
                    plot_item.clear()
            
            clear_plot_items()
            <
            Is there a way to prevent a rectangular pyqtgraph ROI to not move left-right?
            Pythondot img7Lines of Code : 9dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            class ConstantXROI(ROI):
                constant_x = 0
            
                def setPos(self, pos, y=None, update=True, finish=True):
                    pos.setX(self.constant_x)
                    super().setPos(pos, y=y, update=update, finish=finish)
            
            self.twoDIm
            pyqtgraph: Add Items from seperate ViewBox to Legend
            Pythondot img8Lines of Code : 79dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # -*- coding: utf-8 -*-
            """
            Demonstrates a way to put multiple axes around a single plot. 
            (This will eventually become a built-in feature of PlotItem)
            """
            
            import pyqtgraph as pg
            from pyqtgraph.Qt import QtCore, QtGui
            
            pg.mkQApp()
            
            pw = p
            Python PyQtGraph - how to use setTicks?
            Pythondot img9Lines of Code : 14dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from PyQt6.QtWidgets import QApplication
            import pyqtgraph as pg
            
            app = QApplication([])
            
            wavelengths = [610, 680, 730, 760, 810, 860]
            data = [239.23, 233.81, 187.27, 176.41, 172.35, 173.78]
            
            pw = pg.plot(wavelengths, data, symbol="o")
            
            pw.
            copy iconCopy
            import datetime
            import sys
            import time
            from collections import deque
            
            import numpy as np
            import pyqtgraph as pg
            from PyQt5.QtCore import QTime, QTimer
            from pyqtgraph import debug as debug
            from pyqtgraph.Qt import QtGui
            
            
            class TimeAxisItem

            Community Discussions

            QUESTION

            How to solve the self-crash problem of running multiple pyqt or pyqtgraph drawing components?
            Asked 2022-Apr-01 at 03:22

            I designed the interface, and the custom component tried to output multiple drawing components, and the program crashed after a while.

            The program probably consists of the following:ble. Py reads the bluetooth values temporarily holding the EMG array. main_plot.py instantiates the Show_EMG plotting class and outputs the Show_EMG plotting class reading the Bluetooth values of ble.PY

            The program crashed itself without reporting any errors, I tried to output errors at different terminals.

            ERROR MESSAGE:

            CMD:

            pyqtgraph Component Code(Show_EMG.py):

            ...

            ANSWER

            Answered 2022-Mar-31 at 12:43

            Thank @furas and @musicamante suggests, the problem is solved.

            The bug is surprisingly simple.

            I set the refresh rate too fast. Because I setting self.timer.start(10) in the custom component class, So the program crashes itself.🤣It only need setting self.timer.start(100), the program can working...

            Source https://stackoverflow.com/questions/71687893

            QUESTION

            Pyqtgraph's PlotWidget doesn't show correctly
            Asked 2022-Mar-19 at 15:13

            I've been trying to embed a graph into my application using pyqtgraph's PlotWidget. It seemed simple enough while following this tutorial. I have managed to show a graph well enough, the problem is that the graph looks broken. Here is an image of the most simple app I could make to show the problem:

            Bugged graph app

            I used the following code:

            ...

            ANSWER

            Answered 2022-Mar-19 at 15:11

            As @titusjan pointed out, I do have two monitors with different scaling factors. Running the program with the same scaling factors or with just one monitor fixed the problem.

            There also are some workarounds in the issue thread @titusjan provided.

            Source https://stackoverflow.com/questions/71524963

            QUESTION

            Generating Scatter Plot from a Matrix
            Asked 2022-Feb-15 at 03:16

            I have a code that generates random matrices of 0's and 1's, and I'd like to convert these matrices into scatter plots, where the coordinate corresponds to the matrix row/column, and the color of the scatter point corresponds to the value (red if 0, blue if 1 for example).

            I've been able to do this with matplotlib, but my use-case involves generating thousands of these images and matplotlib is quite slow for this purpose. For this reason I've been trying to use pyctgraph, but am running into some trouble.

            Matplotlib code:

            ...

            ANSWER

            Answered 2022-Feb-15 at 03:13

            I think using a nested loop and running plt.scatter inside the loop is where your program is wasting a lot of time. it's best to only run plt.scatter once and instead pass a meshgrid of the (x,y) coordinates with the colors randomly shuffled.

            For example, I can generate the same plot without any loops or conditionals and I only need to call plt.scatter once instead of 5x10 = 50 times (!) for every single point

            Source https://stackoverflow.com/questions/71119222

            QUESTION

            pyqtgraph: fixing the number of strings displayed on the x-axis when using TimeAxisItem and tickStrings
            Asked 2022-Feb-09 at 06:59

            I am making a scrolling graph which will plot real-time sensor data, with time on the x axis. I am a bit confused by the behavior of tickStrings.

            My code is based on the example below (from here). As the number of points plotted increases, the number of x axis strings varies - sometimes it increases and sometimes it decreases . It stabilizes once the deque is full length and the 'scrolling' begins.

            Is it possible to keep the spacing between tick strings the same as the number of plotted points increases? I guess that it might be possible use an approach where blank tick strings are replaced as new data is added, but don't know how to do that.

            Edit: An example of what I wish to achieve is here.

            ...

            ANSWER

            Answered 2022-Feb-02 at 13:32

            To set constant number of ticks, You have to override tickValues method as well. This method generates tick values and tickStrings method gives these values string representation - conversion to human readable time in Your case.

            Here is example of TimeAxisItem You can use in Your code:

            Source https://stackoverflow.com/questions/70920246

            QUESTION

            Adding pyqtgraph to PyQt6
            Asked 2022-Jan-28 at 19:39

            So I am making a GUI using Pyqt6 and want to add graphs inside the Gui with other data, SO when I try adding the graph i get the error bellow:

            call: addWidget(self, QWidget): argument 1 has unexpected type 'PlotWidget' addWidget(self, QWidget, int, int, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'PlotWidget' addWidget(self, QWidget, int, int, int, int, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'PlotWidget'

            The code I have

            ...

            ANSWER

            Answered 2022-Jan-28 at 19:39

            I was trying to reproduce Your issue for a while.
            I succeeded after I install PyQt5 and PyQt6 together in the same environment.

            As @musicamante pointed out, it's important to first import PyQt6 and ONLY after that pyqtgraph. Otherwise QT_LIB is not set properly and only guesses PyQt version from already installed packages in the environment.

            Source https://stackoverflow.com/questions/70887458

            QUESTION

            Symbol '|' in pyqtgraph
            Asked 2022-Jan-20 at 16:25

            I am trying to make a scatter plot with '|' symbol (as of matplotlib) in pyqtgraph. This symbol is not available in pyqtgraph. Could anyone know what should I make to reproduce it?

            ...

            ANSWER

            Answered 2022-Jan-20 at 16:25

            There is indeed no "|" symbol in pyqtgraph.
            However, You can create Your own symbol from any character.
            Here is a short code with function, that creates new symbol from any character:

            Source https://stackoverflow.com/questions/70096424

            QUESTION

            QtWidget is not showing
            Asked 2021-Dec-15 at 21:30

            I am trying to use PyQt5 to show two widgets, the first one is a plot of sin, cos and tan function. I am using the pyqtgraph and used the code that was found in the answer of this question. I am also using another widget that draws a cube using PyOpenGL, by taking the example found in this link. I am trying to show this two widgets in one main widget, which is the main window. My approach is the following

            1. Take a main widget.
            2. In the main widget, use a QVBoxLayout()
            3. In the QVBoxLayout, at two widgets mentioned above

            But when I am running the code, only the plot that is using the pyqtgraph is shown but not the cube that is drawn using PyOpenGL. After a little bit debugging, I was able to find out that the height of the cube widget is setting to 0 by default. I am not sure why this is hapenning. I tried calling glWidget.resize(640,480). But it didn't work. I am new on working with PyQt and PyOpenGL. I think I am missing some details that will allow the height of the glWidget to be greater than 0, if my assumption is correct. Also I am not sure if this is actually possible to do. My current code is given below, it is a little bit messy.

            ...

            ANSWER

            Answered 2021-Dec-15 at 21:30

            It seems that QGLWidget (which, by the way, is deprecated, and QOpenGLWidget should be used instead) doesn't implement sizeHint(), so it returns an invalid size (QSize(-1, -1)), which means that the widget can be possibly resized to a 0 width and/or height.

            Since the plot widget has an expanding size policy (and dynamically reimplements sizeHint()) the result is that the gl widget is completely hidden, having 0 height.

            A possible solution is to add the widgets with a proper stretch argument to the layout.

            If you want both widgets to have the same height, you can do the following:

            Source https://stackoverflow.com/questions/70370167

            QUESTION

            pyqtgraph image point selection
            Asked 2021-Nov-10 at 06:11

            I'm trying to make a tool for my lab for manual image registration--where the user can select some points on two different images to align them. I made this in matplotlib, but zooming in/out was way too slow (I think because the images we're aligning are pretty high res). Is there a good way to do that in pyqtgraph? I just need to be able to select points on two image plots side by side and display where the point selections were.

            Currently I have the images in ImageViews and I tried doing it with imv.scene.sigMouseClicked.connect(mouse_click), but in mouse_click(evt) evt.pos(), evt.scenePos(), and evt.screenPos() all gave coordinates that weren't in the image's coordinates. I also played around with doing the point selection with ROI free handles (since I could get the correct coordinates from those), but it doesn't seem like you could color the handles, which isn't a total deal-breaker I was wondering if there was a better option. Is there a better way to do this?

            ...

            ANSWER

            Answered 2021-Nov-10 at 06:11

            Your question is unclear about how you want the program to match the points, here I provide a simple solution to allow you (1) Show an image. (2) Add points to the image.

            The basic idea is to use a pg.GraphicsLayoutWidget, then add a pg.ImageItem and a pg.ScatterPlotItem, and each mouse click adds a point to the ScatterPlotItem. Code:

            Source https://stackoverflow.com/questions/69862059

            QUESTION

            How do I do multithreading correctly in PyQt5 while reading and writing to a file simultaneously?
            Asked 2021-Oct-17 at 23:16

            In one window, I have a button that, when clicked, I want to execute a method from another module. This method takes an indeterminate amount of time to execute and depends on user input in the terminal. This method creates a file and repeatedly opens it, writes things to the file, and closes the file. At the same time this is running I have a matplotlib graph widget in the window with a plot that I want to update each time something new is written to the file by reading and plotting data from the most recent line of the file.

            To check for changes to the file, I'm using QFileSystemWatcher. Right now, nothing happens while the userInputFunction() is running, but when it finishes I get "data/runName_Rec.txt dataFileCreated". If I then manually edit the file in any way the plotting happens as it should. So it seems the watcher only starts working again and sees that there has been a change in the directory after the userInputFunction() finishes.

            How do I do the multithreading correctly so that the watcher works while userInputFunction() is running?

            As I understand it, nothing in my application will respond until the user input function finishes if I have it running in the main thread of my QT program. To address this I tried moving the execution of the user input method into a worker thread following the example here: https://realpython.com/python-pyqt-qthread/. In this worker I have two methods. One simply does a for loop with a sleep() that takes a while exactly like the example. The other runs my userInputFunction(). The for loop method, run(), does not freeze the GUI. However, runScan() which exicutes the actual process I want does still freeze the GUI. I'm not sure what is going on here. I'm not sure if this means I'm not doing the threading properly or if something else is going on.

            Here is a simplified sample of the relevant parts of my code.

            ...

            ANSWER

            Answered 2021-Oct-17 at 23:16

            The GUI freezes in your case because of this line:

            Source https://stackoverflow.com/questions/69609127

            QUESTION

            matplotlib.pyplot.clim counterpart in pyqtgraph
            Asked 2021-Oct-01 at 17:29

            I want to apply a colormap ("hot") only to a certain range of values of an image. I already know this functionality from matplotlib.pyplot.clim where you have to specify a minimum and a maximum value for the scaling. As I understood it, you should use setLevels([min,max]) for this. I have included a minimal example which shows that both representations are unfortunately not equivalent.

            ...

            ANSWER

            Answered 2021-Oct-01 at 17:29

            This question made its way to the pyqtgraph issue tracker here: https://github.com/pyqtgraph/pyqtgraph/pull/1985#issuecomment-932223288

            Here is some code to generate identical results between the two libraries

            Source https://stackoverflow.com/questions/69367352

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pyqtgraph

            Last released version: pip install pyqtgraph. Latest development version: pip install git+https://github.com/pyqtgraph/pyqtgraph@master. Last released version: conda install -c conda-forge pyqtgraph. To install system-wide from source distribution: python setup.py install. Many linux package repositories have release versions. To use with a specific project, simply copy the pyqtgraph subdirectory anywhere that is importable from your project.
            From PyPI:
            Last released version: pip install pyqtgraph
            Latest development version: pip install git+https://github.com/pyqtgraph/pyqtgraph@master
            From conda
            Last released version: conda install -c conda-forge pyqtgraph
            To install system-wide from source distribution: python setup.py install
            Many linux package repositories have release versions.
            To use with a specific project, simply copy the pyqtgraph subdirectory anywhere that is importable from your project.

            Support

            Report issues on the [GitHub issue tracker](https://github.com/pyqtgraph/pyqtgraph/issues). Post questions to the [mailing list / forum](https://groups.google.com/forum/?fromgroups#!forum/pyqtgraph) or [StackOverflow](https://stackoverflow.com/questions/tagged/pyqtgraph).
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pyqtgraph

          • CLONE
          • HTTPS

            https://github.com/pyqtgraph/pyqtgraph.git

          • CLI

            gh repo clone pyqtgraph/pyqtgraph

          • sshUrl

            git@github.com:pyqtgraph/pyqtgraph.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link