Git Product home page Git Product logo

pyqtgraph's Introduction

PyQtGraph

PyPi conda-forge Build Status Documentation Status

A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6

Copyright 2024 PyQtGraph developers

https://www.pyqtgraph.org

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.

Requirements

PyQtGraph has adopted NEP 29.

This project supports:

  • All minor versions of Python released 42 months prior to the project, and at minimum the two latest minor versions.
  • All minor versions of numpy released in the 24 months prior to the project, and at minimum the last three minor versions.
  • Qt5 5.15, and Qt6 6.2+

Currently this means:

Optional added functionalities

Through 3rd part libraries, additional functionality may be added to PyQtGraph, see the table below for a summary.

Library Added functionality
scipy
  • Image processing through ndimage
  • Data array filtering through signal
    pyopengl
    • 3D graphics
    • Faster image processing
    h5py
    • Export in hdf5 format
    colorcet
    • Add a collection of perceptually uniform colormaps
    matplotlib
    • Export of PlotItem in matplotlib figure
    • Add matplotlib collection of colormaps
    cupy
    • CUDA-enhanced image processing
    • Note: On Windows, CUDA toolkit must be >= 11.1
    numba
    • Faster image processing
    jupyter_rfb
    • Jupyter Notebook support
    • Binder

    Support

    Installation Methods

    • 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
    • Many linux package repositories have release versions.

    Documentation

    The official documentation lives at pyqtgraph.readthedocs.io

    The easiest way to learn PyQtGraph is to browse through the examples; run python -m pyqtgraph.examples to launch the examples application.

    Used By

    Here is a partial listing of some of the applications that make use of PyQtGraph!

    Do you use PyQtGraph in your own project, and want to add it to the list? Submit a pull request to update this listing!

    pyqtgraph's People

    Contributors

    2xb avatar ales-erjavec avatar anntzer avatar bbc131 avatar billy4195 avatar campagnola avatar danielhrisca avatar dependabot[bot] avatar dgoeries avatar dschoni avatar edumur avatar ericdill avatar fake-name avatar gpoulin avatar ibressler avatar ixjlyons avatar j9ac9k avatar jkotan avatar justengel avatar ksunden avatar lesauxvi avatar lidstrom83 avatar meganbkratz avatar nilsnemitz avatar ntjess avatar outofculture avatar paulmueller avatar pijyoi avatar radjkarl avatar wubbzi avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    pyqtgraph's Issues

    Memory Leak when adding GLScatterPlotItem

    I have found that adding and removing the same GLScatterPlotItem in a GLViewWidget causes a memory leak. Here is a script to demonstrate the behavior:

    import numpy as np
    from PySide import QtCore, QtGui
    import sys
    
    import pyqtgraph.opengl as gl
    
    num_points = 10
    refresh_interval = 1  # ms
    
    
    class PlotWidget(QtGui.QWidget):
    
        def __init__(self, parent=None):
            super().__init__(parent)
    
            # Basic layout setup
            self.viewWidget = gl.GLViewWidget()
            layout = QtGui.QVBoxLayout()
            layout.addWidget(self.viewWidget)
            self.setLayout(layout)
    
            # Create out scatter plot item. Note that this leak only happens with
            # scatter items, not with line or mesh items.
            pos = np.random.rand(num_points, 3)
            self.scatter = gl.GLScatterPlotItem(pos=pos)
            self.viewWidget.addItem(self.scatter)
    
            # Create and run timer to repeatedly add and remove scatter item.
            self.timer = QtCore.QTimer()
            self.timer.timeout.connect(self._add_remove)
            self.timer.start(refresh_interval)
    
        def _add_remove(self):
            self.viewWidget.addItem(self.scatter)
            self.viewWidget.removeItem(self.scatter)
    
        def sizeHint(self):
            return QtCore.QSize(800, 800)
    
    
    if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
    
        widget = PlotWidget()
        widget.show()
    
        sys.exit(app.exec_())

    I have tried using other plot items (like GLLinePlotItem and GLAxisItem), and I do not see the memory leak, so it seems only GLScatterPlotItem creates the leak. I have also tried using PyQt4 and the script still generates a memory leak.

    Could this be a problem with binding data to the OpenGL context, but then that data does not get released when the plot item is removed? This is my current theory, because I used the objgraph package to find new Python objects every few seconds, and it couldn't find any. Furthermore, GLScatterPlotItem is the only item I tested that has a non-trivial initializeGL method.

    I will do more investigation. If there is a workaround, I would appreciate that too :)

    Thanks in advance for any help!

    new feature for DockArea tiles Docks in grid if 'position' and 'relativeTo' are unspecified

    hi,
    this new feature is only activated if an additional init-argument 'max_docks_xy' is defined.

    if docks where added before with unspecified 'position' and 'relativeTo' they have been just added to the bottom the DockArea (see first image)

    now they can be positioned for variable 'max_docks_xy'-sizes as follows:
    e.g. max_docks_xy=(2,2):
    [1] -> [1] -> [1,2] -> [1,3]
    .........[2]......[3 ]........[2,4]
    all following Docks are tabbed in [4]

    with gives a much better aspect-ratio and look for the Docks!

    example for max_docks_xy=() resp. original state
    image

    example for max_docks_xy=(2,2)
    image

    example for max_docks_xy=(3,3)
    image

    Crashes when closing pyqtgraph

    Ok, this is mostly to report my findings...

    It seems it's pretty common for pyqtgraph to have crashes (not necessarily only on teardown, but also when some widget is not used and is about to be collected).

    The only way I found to get over this is making sure that GraphicsView.close() and ViewBox.close() are always called -- so, maybe some warning in the application exit saying that close() wasn't properly called could be added?

    My guess on why this happens is because there seem to be cycles in the application (i.e.: a scene has a reference to some item and that item in turn references the scene), this way, when python does a collect (when none of this objects are used anymore), it'll detect a cycle, yet it can't know for sure which is the correct order for the deletion -- and if it guesses wrong and deletes in the wrong order, qt can try to access an item which was already deleted on the teardown (i.e.: if the scene is deleted before a child).

    So, the close() fixes this because we manually decide to delete and remove references to children in the parent -- although a real solution would be not having those cycles in the first place (but it'd need some changes on the basic structure -- I'm not familiar enough with the code to do that, so, I'm not providing a patch for this... but I think it'd the only way to fix the random crashes that can happen when using pyqtgraph when some pyqtgraph widget is not used anymore -- besides calling close() manually, in which case this should probably be made more explicit in the documentation. Also, fixing that should fix the need for the atexit.register issues).

    As a separate note, you can use:
    shiboken.isValid(o) and sip.isdeleted(o) to check if an object is still alive -- I saw some places in the code which catch a RuntimeError, but I think checking before is nicer :)

    Allow consistent, per-item control over antialiasing (and other options)

    Would be nice to have a consistent API for controlling antialiasing and other options across all items. This could be implemented as GraphicsItem.setOptions or .setStyle.

    • All items should be able to extend the list of available options for their own use (and we can finally reach agreement between the various methods used, such as AxisItem.setStyle, ErrorBarItem.setOpts, etc.). But we need to be careful about how this should interact with setData on most items..
    • Many options should have a default value (None, 'default', -1, whatever) that indicates the global default should be used.

    Faster import of pyqtgraph

    Right now, importing pyqtgraph is fairly slow. Compare:

    $ time python -c 'import matplotlib.pyplot'
    real    0m0.442s
    user    0m0.410s
    sys     0m0.030s
    $ time python -c 'import pyqtgraph'
    real    0m1.095s
    user    0m0.943s
    sys     0m0.137s
    

    After profiling the imports I found that the bottlenecks were the imports of scipy.stats (by PlotCurveItem and ScatterPlotItem) and of OpenGL.GL (by RawImageWidget): both of them take more than 200ms, so altogether they contribute to close to half of the total import time.

    But scipy.stats is only imported to provide scoreatpercentile, while numpy.percentile already provides (nearly) the same functionality (the method of rounding when the percentile doesnt fall exactly on a data point isn't the same), and the import of OpenGL could reasonably be delayed until the initialization of RawImageWidget (one could still test for the presence of the module using the importlib machinery). While non-top-level imports are generally frowned upon, I feel like this is a reasonable use case.

    I will prepare a patch but would like to hear your opinion on the topic too.

    BUG# detection of requirements

    In my case against

    kubuntu linux

    after apt-get install scipy
    pyopengl failed when I try to run 3d

    Windows

    After git submodule against my application, failed to find numpy and scipy..
    and eventually installed from . ? (cant remember)

    I think we need to alert users where to download these externals.. maybe
    and dependancies.. even if it means calling vbs, or popping up a single html page..

    • GL / pyopengl could be disabled if not present..
    • the others are fatal..

    Make SpotItem inherit from GraphicsObject

    I discover your lib few days ago and it's really usefull ! Thank you for that !

    I extensively using ScatterPlotItem with a high number of spots. I would like to allow interaction on individual SpotItem coming from the same ScatterPlotItem. For example drawing a rectangle selection and select SpotItem under the rectangle. Fow now I wrote a small code computing if a SpotItem is inside the rectangle but it's very inneficient for a large amount of spots. It turns out that Qt already handle items selection and focus. But because SpotItem does not inherit from GraphicsObject and so from QtGui.QGraphicsObject also, I can't use Qt selection and focus mechanism on individual SpotItem.

    Any reason ?

    Thanks,

    Why is ViewBoxMenu copied?

    Currently, the context menu triggered by a right click on a ViewBox is obtained through ViewBox.getMenu, which returns a copy of self.menu; however the copy is implemented by populating a new menu using a pre-defined list of actions. All this prevents a simple customization of the context menu through viewbox.menu.addAction(...); instead I think one must go through subclassing.
    The comment says that the menu is being copied "to prevent menu disappearing", which isn't very clear to me. For example, the copy is a shallow one -- submenus are shared -- so it's not clear what this achieves. And even then, it may be better to copy the menu by iterating through menu.actions() so that dynamically added entries are kept.
    So there are a few options possible to "fix" this but I'd first like to understand the reason for the current choice of implementation.

    Setting a background image for a plot

    I have a plotting requirement where the background will never change, but a line plot must be layered over it. Is it possible to specify an unchanging background image behind a PlotItem?

    Avoid nesting multiprocessing callbacks

    Take this example:

    import pyqtgraph as pg
    pg.mkQApp()
    
    import pyqtgraph.multiprocess as mp
    proc = mp.QtProcess()
    pg = proc._import('pyqtgraph')
    plt = pg.plot()
    line = plt.addLine(x=0, movable=True)
    
    def cb(*args):
        print "Line moved:", line.value()
    
    proxy = mp.proxy(cb, autoProxy=True, callSync='off')
    line.sigPositionChanged.connect(proxy)
    

    When the line is dragged, the callback may be invoked recursively because calling line.value() causes the event handler to detect new callback requests and invoke them immediately, even though the first call to cb has not completed yet. Instead, the event handler should queue newly received callbacks until the first has completed.

    ViewBox linking broken when aspect ratio is locked

    With the following code, zooming in the right view causes improper range updates in the left view:

    >>> import pyqtgraph as pg
    >>> w = pg.GraphicsWindow()
    >>> v1 = w.addPlot()
    >>> v2 = w.addPlot()
    >>> v1.setAspectLocked()
    >>> v2.setAspectLocked()
    >>> v1.setYLink(v2)
    

    In general, the code responsible for handling this is a mess. In particular, the block in ViewBox.setRange beginning with if aspect is not False begs for a cleaner solution. We need to make sure ViewBox can do all of the following, in any combination:

    • lock to arbitrary aspect ratio
    • link with other views
    • resize appropriately (keeping last-requested range entirely visible)
    • auto-range + options: fractional range, pan only, visible only

    At the same time, avoid recomputing range whenever possible (ideally this should be deferred until immediately before painting, but this is very difficult when some items need to know the range before painting).

    Add support for Qt5

    Are there any plans to add support for PyQt5?

    I see you've got a nice wrapper around the Qt imports to support PySide/PyQt4. I had hoped that would mean a simple copy-pasta PyQt4 > PyQt5 but unfortunately you get hit with errors elsewhere (QApplication now being in QWidgets for example).

    I can have a go at creating a PyQt5 fork in a branch and see how much I have to mangle it before it works, but I wanted to check nobody else was doing this first.

    pyqtgraph should not inject basestring (or other python2 builtins) in the python3 builtins namespace

    For the better or, mostly, the worse, setuptools' pkg_resources uses the presence of basestring in the builtins namespace to check for Python2 vs. Python3. While this is a poor approach, this leads to issues when trying to import pkg_resources after pyqtgraph in Python3:

    $ ipython3 -c "import pyqtgraph, pkg_resources"                     [14-08-04 0:23:44]
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-1-90f3ed1b6919> in <module>()
    ----> 1 import pyqtgraph, pkg_resources
    
    /usr/lib/python3.4/site-packages/pkg_resources.py in <module>()
         48     basestring
         49     next = lambda o: o.next()
    ---> 50     from cStringIO import StringIO as BytesIO
         51 except NameError:
         52     basestring = str
    
    ImportError: No module named 'cStringIO'
    

    (note that the reference to basestring does not raise a NameError despite being run in Python3.)

    The other functions injected, cmp and xrange, could arguably also lead to similar problems.

    I filed a bug for pkg_resources too but ultimately any kind of builtins manipulation is vulnerable to such issues.

    Detecting double click events

    I want to add a function to a PlotWidget, which executes when the user double clicks on the widget. To detect the double-click, I am using the sigMouseClicked signal from the GraphicsScene object, which passes a mouseClickEvent. and I can check the mouseClickEvent's ._double attribute to determine whether the click was a single, or a double click. The mouseDoubleClickEvent from GraphicsScene sets this parameter correctly, but when this function executes, two click events are added to the self.clickevents list (a clickevent with self._double=False, and another event with self._double=True). When the mouseReleaseEvent executes, the self.clickEvents = [] erases the second event without processing it. To solve this, I added a single line to the mouseDoubleClickEvent in GraphicsScene

    self.clickEvents[-1], self.clickEvents[-2] = self.clickEvents[-2], self.clickEvents[-1]

    which, replaces the redundant clickevent with the doubleclickevent, so it will be erased later instead of the clickevent with the correct double attribute. I think the

    self.clickEvents[0], self.clickEvents[1] = self.clickEvents[1], self.clickEvents[0]

    should do the trick, but i dont know, how long the clickEvents list can possibly be (I didn't checked the code fully). I dont know, if this is a correct solution, for my problem, or this replace can cause some other problem later.

    ScatterPlot performance

    In the example ScatterPlotSpeedTest.py, more than half of the computing time is spend on getting symbol property and making pen and brush. In the more standard case, few symbols (probably just one) is going to be used for all the points. The information about the symbols could be computed once and "cached". I'm not really familiar with GraphicsView, but it might also be possible to "prerender" the symbols and "paste" them at the right place.

    GLScatterPlotItem.py Line 149

    Traceback:

    |==============================>>
    |  Traceback (most recent call last):
    |    File "/usr/lib/pymodules/python2.7/pyqtgraph/opengl/GLViewWidget.py", line 180, in drawItemTree
    |      i.paint()
    |    File "/usr/lib/pymodules/python2.7/pyqtgraph/opengl/items/GLScatterPlotItem.py", line 149, in paint
    |      glDrawArrays(GL_POINTS, 0, int(pos.size / pos.shape[-1]))
    |  AttributeError: 'list' object has no attribute 'size'
    |  
    |==============================<<
    

    I'am using Python 2.7.3 and elementaryOS Luna.
    pyqtgraph 0.9.8-1-all.deb

    Thanks.

    Offset between linked views

    An offset appears between linked views when one view is held inside a GraphicsLayout. Example:

    import pyqtgraph as pg
    
    pg.mkQApp()
    w = pg.LayoutWidget()
    
    p1 = pg.PlotWidget()
    v = pg.GraphicsLayoutWidget()
    p2 = v.addPlot()
    
    w.addWidget(p1)
    w.addWidget(v)
    p1.setYLink(p2)
    
    w.show()
    

    Graphics Items prevent autoscaling of visual-data-only

    It seems that using BarGraphItem or FillBetweenItem prevents the auto-scaling of the visible-data-only in plots. To reproduce, use the FillBetween example in the pyqtgraph.example demo -- if one sets autoscale to visible data only on the full data set, the y-axis maximum rattles around between about 8 and 12. But if one pushes most of the full data set out of the visible window and just looks at one side of the other, and resets the settings to auto-scale visible-data only, the y-axis is still maximum of 8-12, not something more appropriate for the reduced data span at the beginning or end of the data set. The apparent disabling of the visible-data-only autoscaling occurs even when I add a regular plot curve to the bar data.

    Curiously, the CandlestickItem used in the Custom Graphics Example (which I adapted slightly to allow for the close == open) will auto-scale very nicely.

    Perhaps all graphics objects need a "boundingRect" function like CandlestickItem has?

    HistogramLUTItem should support multiple orientations

    Right now, HistogramLUTItem really only makes sense to put on the right edge of a layout. It would be really nice if HistogramLUTItem.__init__() took an orientation parameter (i.e., 'left', 'right', 'top', 'bottom'; default to 'right') that made it have a layout appropriate for docking to that side of an image.

    My use case is that my images are short and wide; I'd really like to put the histogram beneath them to
    more efficiently use screen space.

    Crash on exit after exporting a plot

    I have a consistent crash on exit whenever I close a plot after exporting. My code is as follows:

    def plot(data):
        x_data = [w[0] for w in data]
        y_data = [w[1] for w in data]
        win = pg.GraphicsWindow(title="Input versus Output")
    
        # Enable antialiasing for prettier plots
        pg.setConfigOptions(antialias=True)
    
        p1 = win.addPlot(title="Input versus Output")
        p1.setLogMode(False, False)
        p1.plot(x_data, y_data)
    
    # --------------------------------------------------------------------------
    if __name__ == "__main__":
        SHOULD_PLOT = True
    
        if not pyQA400.connect_to_analyzer():
            print "Can't find the analyzer. Exiting."
            sys.exit(1)
    
        initialize_analyzer()
        data = input_versus_output(-100, -10, 2,
                                   generator=pyQA400.GEN2,
                                   input_channel=pyQA400.RIGHTIN)
        if SHOULD_PLOT:
            import pyqtgraph as pg
            plot(data)
            pg.QtGui.QApplication.exec_()
        else:
            print data

    This all runs fine but if I happen to right-click the plot and export it as a .png file, when I close the plot (and the program exits) I get a crash.

    I am running Python 2.7, the latest pyqtgraph (from head) and PySide 1.0.9 on Windows 7, 64-bit.

    Cannot build msvcr library: "msvcr90d.dll" not found

    I installed 64 bit stable package for Windows (64 bit Python 2.7 on Windows 8)
    Trying the examples I see some work some don't. For example, ImageView.py and others that do not work (it seems that all of them use pyqtgraph.ImageView module, one way or another) print this:

    Looking for python27.dll
    Cannot build msvcr library: "msvcr90d.dll" not found
    Looking for python27.dll
    Cannot build msvcr library: "msvcr90d.dll" not found
    Looking for python27.dll
    Cannot build msvcr library: "msvcr90d.dll" not found
    Found executable c:\mingw64\bin\g++.exe
    c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-atonexit.o):atonexit.c:(.text+0xb0): multiple definition of `atexit'
    C:\Python27\libs/libmsvcr90.a(dwbgs01081.o):(.text+0x0): first defined here
    c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o):mingw_helpers.c:(.text+0x0): multiple definition of `_decode_pointer'
    C:\Python27\libs/libmsvcr90.a(dwbgs00231.o):(.text+0x0): first defined here
    c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o):mingw_helpers.c:(.text+0x10): multiple definition of `_encode_pointer'
    C:\Python27\libs/libmsvcr90.a(dwbgs00241.o):(.text+0x0): first defined here
    c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o): bad reloc address 0x0 in section `.pdata'
    collect2.exe: error: ld returned 1 exit status
    

    Why does it look for msvcr library with debug symbols?

    Bad interaction between ViewBox limits and aspect ratio

    When ViewBox computes the constraints specified by setLimits() and lockAspectRatio(), there are some corner cases where the two do not interact nicely. In general, the aspect ratio constraint should be considered the "strongest" constraint, and in the event that this causes a conflict with other constraints, some nice solution should be worked out. This is a tricky problem because the aspect ratio constraint generates an interaction between all x constraints and all y constraints, which can lead to places where a solution exists but is not trivial to compute, since all constraints must be considered simultaneously.

    For example, see: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/pyqtgraph/tiricmZHpQM/BkOIQpA6hKcJ

    buffer doesn't exist in Python3 anymore

    makeQImage and RemoteGraphicsView still use Python2's buffer type, which disappeared in Python3. I can't report a bug example though as the relevant code paths are actually not used under Python3 + PyQt4.10.3 (my setup).

    SpinBox 'decimals' keyword does not affect behavior

    When I make a spinbox, I cannot seem to control the number of digits it shows using the "decimals" parameter. This can be tested by modifying the provided example code.

    Using

    • python2.7
    • pyqtgraph v0.98 win32
    • Windows 7

    NameSpace colliosion

    Just bumped into a strange scenario whils docus in this scenario

    Import posgres as pg
    import pyqtgraph as pg
    

    WOW..

    So can I suggest we use

    import pyqtgraph as pgra ? or alike
    

    Problem here is globals !!

    Don't create global registry of items.

    I noticed that there's a hack in pyqtgraph.GraphicsScene.GraphicsScene.GraphicsScene.translateGraphicsItem which creates a 'global' registry of items... I'm not using PyQt (only PySide), so, that'll not affect me, but maybe a nicer approach could be setting a weakref from the item to itself using setData and then getting it back later on? (I haven't actually tested that, but it seems it should work and would be nicer than creating a global registry...)

    Image export gives incorrect results when specifying size.

    When exporting with ImageExporter, specifying any width other than the default produces erroneous results. In some cases, axis labels are out of place, and in other cases lines do not match up to scatter plot points.

    See this discussion: https://groups.google.com/d/msg/pyqtgraph/qkLUEiFt0Qk/pwiNToIKcMsJ

    Example:

    from PyQt4 import QtCore, QtGui
    import pyqtgraph as pg
    pg.mkQApp()
    
    view = pg.PlotWidget(title='I0-Normalised reflectivity')
    view.setLabel('left', "Reflectivity", units='arb. units')
    view.setLabel('bottom', "Photon energy", units='eV')
    view.showAxis('top', show=True)
    
    exporter = pg.exporters.ImageExporter.ImageExporter(view.plotItem)
    exporter.params['width'] = 1000
    exporter.export('test.png')
    

    Cannot import RawImageGLWidget

    Running the example code on my Ubuntu 14.04 computer (running Anaconda 2.1.0) I cannot get any Image-based examples to run. The error is always something like the one pasted in below. I've tried both the latest release 0.98, and a clone from the latest source. I'd appreciate any help that you can provide.

    Traceback (most recent call last):
    File "", line 21, in
    File "VideoTemplate_pyqt.py", line 220, in
    from pyqtgraph.widgets.RawImageWidget import RawImageGLWidget, RawImageWidget
    ImportError: cannot import name RawImageGLWidget

    Avoid export bug by calling processEvents() before export

    If we try to export programatically from a widget that has just been created, the export fails because the widget has size 0. In this case, it would be better to catch the exception, call processEvents(), and then retry the export. Example:

    import PySide
    import pyqtgraph as pg
    import numpy as np
    data = np.random.normal(size=1000)
    win = pg.GraphicsWindow(title="hi")
    win.resize(800,800)
    p1 = win.addPlot()
    plt = p1.plot(data, title="Simplest possible plotting example")
    # pg.QtGui.QApplication.processEvents() # <-- fixes the bug
    exporter = pg.exporters.ImageExporter.ImageExporter(p1)
    exporter.parameters()['width'] = 800
    exporter.export("yay" + ".png")
    

    ImageExport doesn't plot symbols

    Hi,
    The following code displays correctly in the window (with circular plot markers) but the exported image only has the line.

    pw = pg.plot(x, y, symbol='o')
    ImageExporter(pw.plotItem).export('test.png')

    It works as expected with the previous release but not from master

    Rationale for creating a copy in makeQImage

    Currently makeQImage defaults to passing a copy of the data to QtGui.QImage. In particular, ImageItem does not offer an easy way to override this behavior (without modifying the source).

    But in practice it seems like what gets passed to makeQImage is usually already an intermediate array created by makeARGB (e.g. in the case of ImageItem), so there is no point in making an extra copy(?). Thus, I would like to suggest to defaulting copy to False, or perhaps to a third value, None, which would just means "don't copy the array if you don't need to, i.e. if it is already in the right orientation".

    Please let me know if I am missing something.

    Bug in PlotItem.py: addLine(pos=user_pos, angle=user_angle) cannot work

    Compare
    https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/graphicsItems/PlotItem/PlotItem.py#L570
    specifying the "angle" kwd on the addLine() call will lead to InfiniteLine.__init__(pos, angle, **kwds) being called with two angle keywords (the first, explicit one, and the one in **kwds).

    Suggestion:
    instead of

            angle = kwds.get('angle', 0 if x is None else 90)
    

    do

            kwds['angle'] = kwds.get('angle', 0 if x is None else 90)
    

    InfiniteLine issue when toggling logarithmic axes

    Hello,

    If I add a horizontal infinite line at let's say y=50, when I toggle the y scale to be logarithmic, the line appears at 10^50 instead of at y=50. Tee sample behaviour is observed with the x axis.

    Should it be considered a bug or should I reposition myself the lines when changing from linear to logatirhmic scales?

    Armando

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.