/** \example scatter_customsymbol.cpp * Usage of JKQTPScatterGraph with custom symbols * * \ref JKQTPlotterscatterCustomSymbol */ #include "jkqtpexampleapplication.h" #include #include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/graphs/jkqtpscatter.h" #include "jkqtpexampleapplication.h" #include int main(int argc, char* argv[]) { JKQTPAppSettingController highDPIController(argc,argv); JKQTPExampleApplication app(argc, argv); // 1. create a plotter window and get a pointer to the internal datastore (for convenience) JKQTPlotter plot; JKQTPDatastore* ds=plot.getDatastore(); // 2. add two columns to the JKQTPDatastore and obtain back-inserter iterators for these size_t columnX=ds->addColumn("x"); auto colXInserter=ds->backInserter(columnX); size_t columnY1=ds->addColumn("y1"); auto colY1Inserter=ds->backInserter(columnY1); size_t columnY2=ds->addColumn("y2"); auto colY2Inserter=ds->backInserter(columnY2); size_t columnY3=ds->addColumn("y3"); auto colY3Inserter=ds->backInserter(columnY3); size_t columnY4=ds->addColumn("y4"); auto colY4Inserter=ds->backInserter(columnY4); // 3. now we create data for a simple plot (a sine curve with random noise) const int Ndata=5; for (int i=0; isetXColumn(columnX); graph1->setYColumn(columnY1); graph1->setSymbolType(customsymbol_olympicrings); graph1->setSymbolSize(30); graph1->setTitle(QObject::tr("olympics")); plot.addGraph(graph1); JKQTPXYScatterGraph* graph2=new JKQTPXYScatterGraph(&plot); graph2->setXColumn(columnX); graph2->setYColumn(columnY2); graph2->setSymbolType(customsymbol_coloredolympicrings); graph2->setSymbolSize(30); graph2->setTitle(QObject::tr("colored olympics")); plot.addGraph(graph2); JKQTPXYScatterGraph* graph3=new JKQTPXYScatterGraph(&plot); graph3->setXColumn(columnX); graph3->setYColumn(columnY3); graph3->setSymbolType(JKQTPCharacterSymbol+QChar(0x2660).unicode()); graph3->setSymbolColor(QColor("darkblue")); graph3->setSymbolSize(15); graph3->setTitle(QObject::tr("spades")); plot.addGraph(graph3); JKQTPXYScatterGraph* graph4=new JKQTPXYScatterGraph(&plot); graph4->setXColumn(columnX); graph4->setYColumn(columnY4); graph4->setSymbolType(JKQTPFilledCharacterSymbol+QChar(0x2665).unicode()); graph4->setSymbolSize(20); graph4->setSymbolColor(QColor("black")); graph4->setSymbolFillColor(QColor("red")); graph4->setSymbolLineWidth(0.5); graph4->setTitle(QObject::tr("hearts")); plot.addGraph(graph4); // 6. autoscale the plot so the graph is contained plot.setXY(-0.1,1.1,-1, 6); // show plotter and make it a decent size plot.getXAxis()->setShowZeroAxis(false); plot.getYAxis()->setShowZeroAxis(false); plot.setGrid(false); plot.getPlotter()->setKeyPosition(JKQTPKeyInsideTopLeft); plot.getPlotter()->setPlotLabel(QObject::tr("Custom Scatter Symbols Example")); plot.show(); plot.resize(500/plot.devicePixelRatioF(),500/plot.devicePixelRatioF()); return app.exec(); }