Skip to main content

foamgraph

PyPi Build status Build status

Language Qt 5 Qt 6

foamgraph was originally developed as part of the online analysis framework EXtra-foam to provide fast display (10 Hz) and interactive data analysis for data-intensive photon science experiments at the state-of-art free-electron laser (FEL) facility - European XFEL. It was originally implemented on top of the famous Python graphics and GUI library PyQtGraph. The following features made foamgraph stand out:

  • The widgets are dedicated for photon science experiments.
  • The performance has been significantly improved.

As of now, foamgraph has almost evolved into its own implementation completely. It's time to decide the direction for future development. Since there are already many excellent GUI libraries around, foamgraph should and will do something different.

Getting started

Imaging you have a data producer which streams data continuously and you would like to build a GUI to visualize the data and perform interactive analysis while the data is updating. Eventually, what you need is something shown in the code snippet below: a consumer consumers the data generated by the producer and then passes the data to the GUI.

gui = PlotGalleryWindow()
consumer = Consumer(gui.queue)  # the queue is used to store data streams

gui.start()
consumer.start()

The class PlotGalleryWindow can be conveniently implemented as follows:

class PlotGalleryWindow(LiveWindow):
    def __init__(self):
        super().__init__("Plot gallery")

        # define your plots
        self._plots = [
            ShadedPlot(parent=self),
            ScatterPlot(parent=self),
            BarPlot(parent=self),
            ErrorbarPlot(parent=self),
            MultiLinePlot(parent=self),
            DoubleYPlot(parent=self),
            LinePlotWithAnnotation(parent=self),
            CandlestickPlot(parent=self),
            StemPlot(parent=self)
        ]

        # init your GUI layout and Qt signal-slot connection
        self.init()

For more details of the above use case, please check here.

In foamgraph, every plot widget should inherit from GraphView. The following code snippet shows how to create a double-y plot with a title, axis labels and a legend:

from foamgraph import FColor, GraphView


class DoubleYPlot(GraphView):
    def __init__(self, *, parent=None):
        super().__init__(parent=parent)

        self.setTitle('Double-y plot')
        self.setXYLabels("x (arb. u.)", "y (arb. u.)", y2="y2 (arg. u.)")

        self._plot = self.addCurvePlot(label="Data", pen=FColor.mkPen('w'))
        self._plot2 = self.addBarPlot(
            label="Count", y2=True, brush=FColor.mkBrush('i', alpha=150))
        self.addLegend()

    def updateF(self, data):
        """Override."""
        self._plot.setData(data['x'], data['y'])
        self._plot2.setData(data['x'], data['y2'])

Examples

  • Open a terminal and start the producer:
python examples/producer.py
  • Open another terminal and start the plot gallery example
python examples/plot_gallery.py
  • Open another terminal and start the image analysis example
python examples/image_analysis.py

Benchmarks

The benchmark was performed on a Apple M1 Pro 16GB with the GUI geometry of 800 x 600.

Plot Type Description FPS
Curve 10000 points 300
Scatter 10000 points 140
Bar 500 bars 350
Image 1280 x 1024 92

Metadata

Release files for foamgraph 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foamgraph 0.2.4
File Size Uploaded Provenance Actions
foamgraph-0.2.4.tar.gz 76.5 kB Without provenance Details for foamgraph-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for foamgraph 0.2.4
File Interpreter ABI Platform Actions
foamgraph-0.2.4-py3-none-any.whl Python 3 none any Details for foamgraph-0.2.4-py3-none-any.whl

Total release size: 189.2 kB

Release files / foamgraph-0.2.4.tar.gz

Download URL foamgraph-0.2.4.tar.gz
Size 76.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1a7b1de9cf7d5f64fb2d52cd64da8529b16ff24344f5017a05b227bfe672167a
BLAKE2b-256 checksum
How to use checksums
543e4b79d094aab85df78530e0e88de760543ad8d041cf0e7c38ba5318bf56f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / foamgraph-0.2.4-py3-none-any.whl

Download URL foamgraph-0.2.4-py3-none-any.whl
Size 112.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
706bd9502361eb5bb52fdd60e1166fdb9423108158dac25b78739be1b933b32e
BLAKE2b-256 checksum
How to use checksums
6702671b238918c541146993a8701328f83c6771d8bb3ab4e5d8304c5a62dabc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for foamgraph 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page