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
Loading...
Searching...
No Matches
Tool (JKQTMathText): Command-Line Utility jkqtplotter_doc_imagegenerator

This command-line tool is used to generate images for the documentation.

For some of its options, it uses a JKQTBasePlotter to directly render an image without creating a visible window. The code then looks like this:

First we generate the JKQTBasePlotter object and add some data to the internal JKQTPDatastore

JKQTBasePlotter plot(true);
JKQTPDatastore* ds=plot.getDatastore();
size_t cx=ds->addCopiedColumn(QVector<double>{-1.5,-0.5,0.5,1.5,2.5},"x");
size_t cy=ds->addCopiedColumn(QVector<double>{-0.75,-0.3,-0.05,0.2,0.65},"y");
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter t...
Definition jkqtpdatastorage.h:282
size_t addCopiedColumn(TIterator first, TIterator last, const QString &name=QString(""))
add one column to the datastore. It will be filled with the values from first ... last
Definition jkqtpdatastorage.h:871

Now we set the range of x/y plot coordinates ...

plot.setXY(-0.8,2.2,-0.5,0.7);

and the size of the widget, i.e. the size of the plot in the windowing system.

plot.setWidgetSize(150,50);

Now we can add graphs to the plotter, e.g.

g->setXColumn(cx);
g->setYColumn(cy);
plot.addGraph(g);
void setYColumn(int __value)
the column that contains the y-component of the datapoints
void setXColumn(int __value)
the column that contains the x-component of the datapoints
This implements xy line plots. This also alows to draw symbols at the data points.
Definition jkqtplines.h:61

Finally we store an image of the plot as PNG-file:

plot.saveAsPixelImage("output.png", false, "png");