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
Example (JKQTPlotter): Plot With Axes through Origin

This example draws a coordinate system with several geomtric shapes, where the coordinate axes pass through the origin of the plot, not at the borders. Note that if you move the displayed coordinate ranges, so 0 is not in them, the axes still stick to the borders.

The source code of the main application can be found in geo_coordinateaxis0.cpp.

Apart from the usual code to set up the graphs, the following fragment switches the "normal" axes at the borders off and the zero axis on:

plot.getXAxis()->setShowZeroAxis(false);
plot.getYAxis()->setShowZeroAxis(false);
plot.getXAxis()->setDrawMode1(JKQTPCADMnone);
plot.getXAxis()->setDrawMode2(JKQTPCADMnone);
plot.getXAxis()->setDrawMode0(JKQTPCADMcomplete|JKQTPCADMMaxFilledArrow);
plot.getXAxis()->setLabelPosition(JKQTPLabelMax);
plot.getXAxis()->setAxisLabel("$X$ Coordinate");
plot.getYAxis()->setDrawMode1(JKQTPCADMnone);
plot.getYAxis()->setDrawMode2(JKQTPCADMnone);
plot.getYAxis()->setDrawMode0(JKQTPCADMcomplete|JKQTPCADMMaxFilledArrow);
plot.getYAxis()->setLabelPosition(JKQTPLabelMax);
plot.getYAxis()->setAxisLabel("$Y$ Coordinate");
@ JKQTPCADMMaxFilledArrow
draw a filled arrow at the max-end of the axis
Definition jkqtptools.h:409
@ JKQTPCADMcomplete
draw axis withline, ticks, ticklabels and axis label
Definition jkqtptools.h:419
@ JKQTPCADMnone
draw no axis
Definition jkqtptools.h:418
@ JKQTPLabelMax
the axis label is near the max value of the axis (right/top)
Definition jkqtptools.h:512

The axes are configured to have an arrow at their max end (|JKQTPCADMMaxFilledArrow) and the axis label is also positioned close to the axis max.

The resulting plot looks like this:

geo_coordinateaxis0