mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
be48ed84ba
add qt5.12.12 compatibility QList::swapItemsAt was introduced in Qt 5.13. and more ,,, thanks to https://github.com/Social-Mean |
||
---|---|---|
.. | ||
CMakeLists.txt | ||
jkqtplotter_doc_imagegenerator_and_lib.pro | ||
jkqtplotter_doc_imagegenerator.cpp | ||
jkqtplotter_doc_imagegenerator.pro | ||
README.md |
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");
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.
JKQTPXYLineGraph* g=new JKQTPXYLineGraph(&plot);
g->setXColumn(cx);
g->setYColumn(cy);
plot.addGraph(g);
Finally we store an image of the plot as PNG-file:
plot.saveAsPixelImage("output.png", false, "png");