JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
It is also possible to use it in a standalone fashion to generate plots without generating a window. Note that the baseplotter class still requires the widgets+gui
modules of Qt, because it contains code to e.g. display pint or export preview dialogs!
Here is an example of how to do this (it is taken from the command-line tool Tool (JKQTMathText): Command-Line Utility jkqtplotter_doc_imagegenerator):
First we generate the JKQTBasePlotter object and add some data to the internal JKQTPDatastore
Now we set the range of x/y plot coordinates ...
and the size of the widget, i.e. the size of the plot in the windowing system.
Now we can add graphs to the plotter, e.g.
Finally we store an image of the plot as PNG-file:
Alternatively you can obtain a QImage of the plot using JKQTBasePlotter::grabPixelImage() or copy the image to the clipboard using JKQTBasePlotter::copyPixelImage(). Also storages as PDF and SVG is available via JKQTBasePlotter::saveAsPDF() and JKQTBasePlotter::saveAsSVG().
With simlar code you can also integrate JKQTBasePlotter into your own widgets.
This class is immpleented in a such a way that different instances can be used in different parallel threads, i.e. the class is re-entrant. There are however access to different cached data is synchronized between all threads (i.e. static internal caches are used), which limmits the acheavable parallelization speedup!
See Example (JKQTPlotter): Multi-Threaded (Parallel) Plotting for an example of multi-threaded plotting!