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
|
This project (see ./examples/paramscatterplot/
) demonstrates the capabilities of JKQTPXYParametrizedScatterGraph
. This graph class plots symbol&line-graphs, juts like JKQTPXYLineGraph
and in addition modifies several properties of each plot point by data from an additional column. These properties can be modified:
The source code of the main application can be found in paramscatterplot.cpp
. First, several datasets are generated and added to the internal datastore. the resulting datatable looks like this:
Then several plots are added that modify different properties.
The simplest case is to modify the symbol type. Simply set the property symbolColumn
with graph1->setSymbolColumn(columnP)
to a data column. The values in the data column will be cast to an integer and then will be translated to JKQTPGraphSymbols
. If the numbers are larger than the available symbol types in JKQTPGraphSymbols
, the graph will cycle through the available symbols (via a modulo-operation with the max. symbol count!).
The next two code snippets show how to modify the size of the symbols and the line width of the lines, connecting the symbols (ensure to set graph6->setDrawLine(true)
, because otherwise no line will be drawn). The principle is the same as above, but here you need to set the properties sizeColumn
for the symbol size and linewidthColumn
for the line width. All values in the line width or symbol size columns are interpreted as sizes in dtp points (pt)!
Finally you can set the color of each symbol, based on data in the column colorColumn
. Here two possibilities exist: First you can store the RGB(A) value for each datapoint explicitly. For this, you first need to create the data in the column, using the Qt-function qRgb()
or [qRgba()
}(http://doc.qt.io/qt-5/qcolor.html#qRgba):
.cpp Basically the data points in a RGB(A)-column will be interpreted by castig them to QRgb
.
Now you can add the graph. In order to interpret the color column as RGB(A)-values, ensure to set graph4->setColorColumnContainsRGB(true)
:
The second variant for setting the color of each datapoint is by mapping the values in the column to a color palette (JKQTPMathImageRYGB
in this example). For this you simply need to define the color coumn and the palette to use. By default, the color palette spans the full range of values in colorColumn
:
Note: If you want to set the range manually, use ste_imageMin()
and setImageMax()
after setting setAutoImageRange(false)
.
Note also that it is possible to combine any of parametrizations above in a single graph, by setting two or more columns:
The full test appication combines all these variants and the result looks like this:
In `you can also set special functors that transform the values from the data columns (symbol type+size, datapoint), before using them for the plot, which gives you even more control. As an example you can set a special functor to
graph6`:
This will result in modulated linewidths as shown below:
The same can be done for symbol type, e.g. with code like this:
This will result in symbols as shown below:
As an alternaitve for symbols, you can define the functor also in terms of a QMap:
This will result in symbols as shown below: