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

this virtual class is the base for any type of coordinate axis, to be drawn by JKQTBasePlotter. More...

#include <jkqtpcoordinateaxes.h>

Inheritance diagram for JKQTPCoordinateAxis:
[legend]
Collaboration diagram for JKQTPCoordinateAxis:
[legend]

Classes

struct  Axis0ElementsSizeDescription
 
struct  AxisElementsSizeDescription
 return value type for getSize1() and getSize2() More...
 

Public Slots

void resetTickUnit ()
 resets tickUnitFactor and tickUnitName in one call
 
void setAbsoluteRange (double aamin, double aamax)
 sets absolutely limiting range of the plot
 
void setArrowSizeFactor (double f)
 factor used to calculate the size of line arrows
 
void setAutoAxisSpacing (bool __value)
 calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )
 
void setAxisColor (const QColor &__value)
 color of the axis (labels, ticks, axis itself ...)
 
void setAxisLabel (const QString &__value)
 axis label of the axis
 
void setAxisMinWidth (double __value)
 absolute minimum range width, feature switched off when <0
 
void setColor (QColor c)
 sets all colors (line, ticks, label, ...) of the axis
 
void setDrawGrid (bool __value)
 indicates whether to draw the major grid lines
 
void setDrawMinorGrid (bool __value)
 indicates whether to draw the major grid lines
 
void setDrawMode0 (JKQTPCADrawMode __value)
 draw mode of the zero axis
 
void setDrawMode1 (JKQTPCADrawMode __value)
 draw mode of the main (left/bottom) axis
 
void setDrawMode2 (JKQTPCADrawMode __value)
 draw mode of the secondary (right/top) axis
 
void setGridColor (const QColor &__value)
 color of the grid
 
void setGridColor (const QColor &__value, double alpha)
 color of the grid
 
void setGridStyle (Qt::PenStyle __value)
 line stye of the grid lines
 
void setGridWidth (double __value)
 width of the grid lines (in pixel)
 
void setInverted (bool __value)
 indicates whether the axis is to be inverted or not
 
void setLabelColor (QColor c)
 color of the axis label
 
void setLabelDigits (int __value)
 digits used for tick labels
 
void setLabelDistance (double __value)
 distance between tick label and axis label in pt
 
void setLabelFontSize (double __value)
 fontsize of the axis labels
 
void setLabelPosition (JKQTPLabelPosition __value)
 position of the axis label
 
void setLineWidth (double __value)
 line width of axis in pt
 
void setLineWidthZeroAxis (double __value)
 line width of 0-line in pt
 
void setLogAxis (bool __value)
 indicates whether the y axis has a logarithmic scale
 
void setLogAxisBase (double __value)
 the base for a logarithmic x axis
 
void setMax (double amax)
 set axis minimum range of plot axis
 
void setMin (double amin)
 set axis minimum range of plot axis
 
void setMinorGridColor (const QColor &__value)
 color of the grid
 
void setMinorGridColor (const QColor &__value, double alpha)
 color of the grid
 
void setMinorGridStyle (Qt::PenStyle __value)
 line stye of the grid lines
 
void setMinorGridWidth (double __value)
 width of the grid lines (in pixel)
 
void setMinorTickColor (QColor c)
 color of minor ticks
 
void setMinorTickInsideLength (double __value)
 length of a minor axis tick inside the plot border in pt
 
void setMinorTickLabelColor (QColor c)
 color of minor tick labels
 
void setMinorTickLabelFontSize (double __value)
 fontsize of the minor axis tick labels
 
void setMinorTickLabelFullNumber (bool __value)
 indicates whether the minor tick labels should be full numbers, or just a number between 0..10
 
void setMinorTickLabelsEnabled (bool __value)
 if true, the plotter displays minor axis labels as number between 1 and 10 in some cases
 
void setMinorTickOutsideLength (double __value)
 length of a minor axis tick outside the plot border in pt
 
void setMinorTicks (int __value)
 number of minor grid lines per (major) axis tick interval
 
void setMinorTicks (unsigned int __value)
 number of minor grid lines per (major) axis tick interval
 
void setMinorTickWidth (double __value)
 line width of minor ticks in pt
 
void setMinTicks (unsigned int __value)
 minimum number of axis ticks
 
void setNoAbsoluteRange ()
 do not use an absolute range of plot axis
 
void setRange (double amin, double amax)
 set range of plot axis
 
void setRangeFixed (bool fixed)
 fixes/ufixes the axis
 
void setShowZeroAxis (bool __value)
 indicates whether to draw a thick axis line at x=0 (zero axis)
 
void setTickColor (QColor c)
 color of axis ticks
 
void setTickDateFormat (const QString &__value)
 format string for date tick labels, see QDateTime::toString() documentation for details on format strings
 
void setTickDateTimeFormat (const QString &__value)
 format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings
 
void setTickFormatFormat (const QString &__value)
 format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification ). The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "\\texttt{{ y={:*^+8.1f}}}":
 
void setTickInsideLength (double __value)
 length of an axis tick inside the plot border in pt
 
void setTickLabelAngle (double __value)
 rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)
 
void setTickLabelColor (QColor c)
 color of axis tick labels
 
void setTickLabelDistance (double __value)
 distance between tick end and label start in pt
 
void setTickLabelFontSize (double __value)
 fontsize of the axis tick labels
 
void setTickLabelType (JKQTPCALabelType __value)
 indicates how to draw the labels
 
void setTickMode (int __value)
 mode of the major ticks
 
void setTickMode (JKQTPLabelTickMode __value)
 mode of the major ticks
 
void setTickOutsideLength (double __value)
 length of an axis tick outside the plot border in pt
 
void setTickPrintfFormat (const QString &__value)
 format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string documentation for details on format strings The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "y=%+.2f":
 
void setTickTimeFormat (const QString &__value)
 format string for time tick labels, see QDateTime::toString() documentation for details on format strings
 
void setTickUnit (double factor, const QString &name)
 sets tickUnitFactor and tickUnitName in one call
 
void setTickUnitFactor (double __value)
 tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)
 
void setTickUnitName (const QString &__value)
 name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...
 
void setTickUnitPi ()
 sets pi-scaling for tickUnitFactor and tickUnitName in one call
 
void setTickWidth (double __value)
 line width of ticks in pt
 
void setUserLogTickSpacing (double __value)
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 
void setUserTickSpacing (double __value)
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 

Public Member Functions

 JKQTPCoordinateAxis (JKQTBasePlotter *parent)
 class constructor
 
virtual ~JKQTPCoordinateAxis ()
 class destructor
 
void addAxisTickLabel (double x, const QString &label)
 add a new tick label to the axis
 
void addAxisTickLabels (const double *x, const QString *label, int items)
 add a new tick label to the axis
 
void addAxisTickLabels (const double *x, const QStringList &label)
 add a new tick label to the axis
 
void addAxisTickLabels (const QVector< double > &x, const QString *label)
 add a new tick label to the axis
 
void addAxisTickLabels (const QVector< double > &x, const QStringList &label)
 add a new tick label to the axis
 
void calcPlotScaling (bool force=false)
 calculate the scaling and offset values from axis min/max values
 
void clearAxisTickLabels ()
 clear axis tick labels. This switches back to automatic labels mode for the axis.
 
virtual void drawAxes (JKQTPEnhancedPainter &painter, int move1=0, int move2=0)=0
 draw the axes
 
virtual void drawGrids (JKQTPEnhancedPainter &painter)=0
 draw grids

 
QString floattolabel (double data) const
 convert a float to a tick label string
 
QString floattolabel (double data, int past_comma) const
 convert a float to a tick label string with a given precision
 
double getAbsoluteMax () const
 returns the current absolute max
 
double getAbsoluteMin () const
 returns the current absolute min
 
double getArrowSizeFactor () const
 factor used to calculate the size of line arrows
 
bool getAutoAxisSpacing () const
 calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )
 
bool getAutoLabelDigits () const
 when true, the digits of the labels are calculated automatically
 
QColor getAxisColor () const
 color of the axis (labels, ticks, axis itself ...)
 
QString getAxisLabel () const
 axis label of the axis
 
const JKQTPCoordinateAxisStylegetCurrentAxisStyle () const
 current style properties for this JKQTBasePlotter
 
bool getDoUpdateScaling () const
 can be used to switch off calcPlotScaling() temporarily, while modifying some properties
 
bool getDrawGrid () const
 indicates whether to draw the major grid lines
 
bool getDrawMinorGrid () const
 indicates whether to draw the major grid lines
 
JKQTPCADrawMode getDrawMode0 () const
 draw mode of the zero axis
 
JKQTPCADrawMode getDrawMode1 () const
 draw mode of the main (left/bottom) axis
 
JKQTPCADrawMode getDrawMode2 () const
 draw mode of the secondary (right/top) axis
 
QColor getGridColor () const
 color of the grid
 
Qt::PenStyle getGridStyle () const
 line stye of the grid lines
 
double getGridWidth () const
 width of the grid lines (in pixel)
 
bool getInverted () const
 indicates whether the axis is to be inverted or not
 
QColor getLabelColor () const
 color of the axis label
 
int getLabelDigits () const
 digits used for tick labels
 
double getLabelDistance () const
 distance between tick label and axis label in pt
 
double getLabelFontSize () const
 fontsize of the axis labels
 
JKQTPLabelPosition getLabelPosition () const
 position of the axis label
 
double getLineWidth () const
 line width of axis in pt
 
double getLineWidthZeroAxis () const
 line width of 0-line in pt
 
bool getLogAxis () const
 indicates whether the y axis has a logarithmic scale
 
double getLogAxisBase () const
 the base for a logarithmic x axis
 
double getMax () const
 returns the current max
 
double getMin () const
 returns the current min
 
QColor getMinorGridColor () const
 color of the grid
 
Qt::PenStyle getMinorGridStyle () const
 line stye of the grid lines
 
double getMinorGridWidth () const
 width of the grid lines (in pixel)
 
QColor getMinorTickColor () const
 color of minor ticks
 
QColor getMinorTickLabelColor () const
 color of minor tick labels
 
double getMinorTickLabelFontSize () const
 fontsize of the minor axis tick labels
 
bool getMinorTickLabelFullNumber () const
 indicates whether the minor tick labels should be full numbers, or just a number between 0..10
 
bool getMinorTickLabelsEnabled () const
 if true, the plotter displays minor axis labels as number between 1 and 10 in some cases
 
double getMinorTickOutsideLength () const
 length of a minor axis tick outside the plot border in pt
 
unsigned int getMinorTicks () const
 number of minor grid lines per (major) axis tick interval
 
double getMinorTickWidth () const
 line width of minor ticks in pt
 
unsigned int getMinTicks () const
 minimum number of axis ticks
 
JKQTBasePlottergetParent ()
 parent plotter class
 
const JKQTBasePlottergetParent () const
 parent plotter class
 
virtual bool getParentOtheraxisInverted () const =0
 is other (perpendicular) axis inverted (needed for grids)
 
virtual double getParentOtheraxisOffset () const =0
 pixel offset of (perpendicular) other axis (needed for grids)
 
virtual double getParentOtheraxisWidth () const =0
 width of other (perpendicular) axis (needed for grids)
 
virtual double getParentPlotOffset () const =0
 offset of the plot in the direction of the axis
 
virtual double getParentPlotWidth () const =0
 width of the plot in the direction of the axis
 
bool getShowZeroAxis () const
 indicates whether to draw a thick axis line at x=0 (zero axis)
 
virtual AxisElementsSizeDescription getSize1 (JKQTPEnhancedPainter &painter)=0
 returns the sizerequirement of the left/bottom axis in pixels
 
virtual AxisElementsSizeDescription getSize2 (JKQTPEnhancedPainter &painter)=0
 returns the size of the right/top axis in pixels
 
QColor getTickColor () const
 color of axis ticks
 
QString getTickDateFormat () const
 format string for date tick labels, see QDateTime::toString() documentation for details on format strings
 
QString getTickDateTimeFormat () const
 format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings
 
QString getTickFormatfFormat () const
 format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification ). The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "\\texttt{{ y={:*^+8.1f}}}":
 
double getTickLabelAngle () const
 rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)
 
QColor getTickLabelColor () const
 color of axis tick labels
 
double getTickLabelDistance () const
 distance between tick end and label start in pt
 
double getTickLabelFontSize () const
 fontsize of the axis tick labels
 
JKQTPCALabelType getTickLabelType () const
 indicates how to draw the labels
 
JKQTPLabelTickMode getTickMode () const
 mode of the major ticks
 
double getTickOutsideLength () const
 length of an axis tick outside the plot border in pt
 
QString getTickPrintfFormat () const
 format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string documentation for details on format strings The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "y=%+.2f":
 
double getTickSpacing () const
 calculated property: axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes.
 
QString getTickTimeFormat () const
 format string for time tick labels, see QDateTime::toString() documentation for details on format strings
 
double getTickUnitFactor () const
 tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)
 
QString getTickUnitName () const
 name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...
 
double getTickWidth () const
 line width of ticks in pt
 
double getUserLogTickSpacing () const
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 
double getUserTickSpacing () const
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 
bool isAxisRangeFixed () const
 returns whether the axis range is fixed, i.e. may not change!
 
bool isLinearAxis () const
 returns whether this axis uses linear scaling (is false e.g. for isLogAxis()==true)
 
bool isLogAxis () const
 returns whether this axis uses logarithmic scaling
 
void loadCurrentAxisStyle (const QSettings &settings, const QString &group="plot/axes/")
 replace the current style properties for this JKQTBasePlotter with properties loaded from settings
 
virtual void loadSettings (const QSettings &settings, const QString &group=QString("plots/axes/"))
 loads the plot properties from a QSettings object
 
double p2x (double x) const
 return x coordinate from x-pixel
 
virtual double parentOtherAxisX2P (double x) const =0
 calls x2p() of the other axis (or returns NAN if the other axis does not exist
 
void saveCurrentAxisStyle (QSettings &settings, const QString &group="plot/axes/") const
 store the current style properties for this JKQTBasePlotter with properties loaded from settings
 
virtual void saveSettings (QSettings &settings, const QString &group=QString("plots/axes/")) const
 saves the plot properties into a QSettings object.
 
void setAutoLabelDigits (bool __value)
 when true, the digits of the labels are calculated automatically
 
void setCurrentAxisStyle (const JKQTPCoordinateAxisStyle &style)
 replace the current style properties for this JKQTBasePlotter
 
void setDoUpdateScaling (bool __value)
 can be used to switch off calcPlotScaling() temporarily, while modifying some properties
 
virtual void setParent (JKQTBasePlotter *parent)
 
double x2p (double x) const
 return x-pixel coordinate from x coordinate
 

Protected Member Functions

double calcLinearTickSpacing ()
 calculates the tick spacing for a linear axis that spans awidth and that should show at least JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks.
 
int calcLinearUnitDigits ()
 Calculate the number of digits needed for the labels of an axis that starts at minval and where the tick spacing is tickSpacing.
 
double calcLogTickSpacing ()
 same as calcLinearTickSpacing(), but for logarithmic scaling
 
void drawAxisLine (JKQTPEnhancedPainter &painter, const QLineF &l, JKQTPCADrawMode drawMode) const
 draw the axis line l (pointing from axismin to axismax) optionally decorated as specified by drawMode using JKQTPEnhancedPainter painter
 
QSizeF getMaxTickLabelSize (JKQTPEnhancedPainter &painter, double *ascent=nullptr, double *descent=nullptr)
 calculates the maximum width and height (returned as QSize) of all tick labels. Ascent and descent may also be returned in the two additional pointer arguments-
 
bool getNextLabel (double &x, QString &label, bool init=false)
 calculates the next label from the given parameters.
 
double getNextLabelDistance (double x)
 returns the distance from the current tick position (x before call) to the next tick position
 
JKQTMathTextgetParentMathText ()
 retun parents JKQTMathText* object
 
const JKQTMathTextgetParentMathText () const
 retun parents JKQTMathText* object
 
virtual Axis0ElementsSizeDescription getSize0 (JKQTPEnhancedPainter &painter)
 returns the size of the zero axis in pixels, the first part of the return-value is the lhs size and the second part the rhs size
 
double getZeroAxisPos (bool *drawZeroAxis=nullptr)
 calculate the position of the zero-axis (and whether to draw it or not)
 
virtual bool isSecondaryAxis () const
 figures out (possibly by probing the parent JKQTBasePlotter), whether this axis is a secondary axis
 
void redrawPlot ()
 simply calls the redrawPlot method of the parent plotter class
 

Protected Attributes

bool autoAxisSpacing
 calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )
 
double axisabsoultemax
 absoulte maximum of axis (axismin/axismax xan not be set above this)
 
double axisabsoultemin
 absoulte minimum of axis (axismin/axismax xan not be set below this)
 
QString axisLabel
 axis label of the axis
 
double axismax
 current view: maximum of axis
 
double axismin
 current view: minimum of axis
 
double axisMinWidth
 absolute minimum range width, feature switched off when <0
 
QString axisPrefix
 axis prefix for storage of parameters
 
bool axisRangeFixed
 indicates whether this axis is fixed, i.e. axismin and axismax are frozen to their current values
 
JKQTPCoordinateAxisStyle axisStyle
 current style properties for this coordinate axis instance
 
bool doUpdateScaling
 can be used to switch off calcPlotScaling() temporarily, while modifying some properties
 
bool inverted
 indicates whether the axis is to be inverted or not
 
bool logAxis
 indicates whether the y axis has a logarithmic scale
 
double logAxisBase
 the base for a logarithmic x axis
 
double offset
 calculated property: axis offset (calculated by calcPlotScaling() )
 
bool paramsChanged
 indicates whether one of the parameters has changed sinse the last recalculation of tickSpacing ...
 
JKQTBasePlotterparent
 parent plotter class
 
double scale
 calculated property: axis scaling factor (calculated by calcPlotScaling() )
 
double scaleSign
 this is used by x2p() and p2x() to determine the sign
 
QVector< QPair< double, QString > > tickLabels
 a list of tick labels.
 
double tickSpacing
 calculated property: axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes.
 
double tickSpacingLog
 calculated property: axis tick spacing for logarithmic JKQTPCoordinateAxisStyle::ticks (calculated by calcPlotScaling() and calcTickSpacing() ) axes.
 
double tickStart
 calculated property: x position of the first tick (calculated by calcPlotScaling() ). Given in system coordinates, not pixel coordinates.
 
double tickUnitFactor
 tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)
 
QString tickUnitName
 name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...
 
double userLogTickSpacing
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 
double userTickSpacing
 if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.
 
double width
 calculated property: width of plot on axis (calculated by calcPlotScaling() )
 

Detailed Description

this virtual class is the base for any type of coordinate axis, to be drawn by JKQTBasePlotter.

Classes derived from JKQTPCoordinateAxis implements all the functionality needed for a coordinate axis:

  • transform world to screen coordinates and vice versa
  • draw the axis (implemented by child classes!) with these elements: axis lines, ticks, tick labels, axis label, x/y=0 axis
  • measure the axes in screen coordinates
  • load and save the settings to an ini file

Most of the actual draw and measure functions have to be implemented in descendents of this class (namely JKQTPHorizontalAxis and JKQTPVerticalAxis, as they are specific to whether the axis is drawn horizontally or vertically.

Each axis is split up into several parts, as depicted in this image:

Which parts to actually draw is set by the diverse properties.

Coordinate Systems and Transformations

The plot itself is positioned inside the widget (see Plot Sizes & Borders for details). You simply supply the widget dimensions and the border widths between the plot and the widget. The Object then calculates the size of the plot:

The plot shows the parameter range xmin ... xmax and ymin ... ymax. Note that if you plot logarithmic plots you may only plot positive (>0) values. Any other value may lead to an error or unpredictable behaviour.

From these parameters the object calculates the scaling laws for plotting pints to the screen. The next paragraphs show all calculations for x- and y-coordinates, ahough this class only implements a generic form. The actual calculation is also influenced by the parameters set in the child classes!

  1. width = xmax - xmin
  2. height = ymax - ymin
  3. plotWidth = widgetWidth - plotBorderLeft - plotBorderRight
  4. plotHeight = widgetHeight - plotBorderTop - plotBorderBottom
  5. xPlotOffset = plotBorderLeft
  6. yPlotOffset = plotBorderTop

These parameters are common to all scaling laws. The next image explains these formulas:

The actual scaling laws $ (x_p(x), y_p(y)) $ may be derived from these equations:

\[ x_p(\mbox{xmin})=\mbox{xPlotOffset},\ \ \ \ \ x_p(\mbox{xmax})=\mbox{xPlotOffset}+\mbox{plotWidth} \]

\[ y_p(\mbox{ymax})=\mbox{yPlotOffset},\ \ \ \ \ y_p(\mbox{ymin})=\mbox{yPlotOffset}+\mbox{plotHeight} \]

Here $ (x_p, y_p) $ denotes a point in pixel coordinates (green coordinate system) and $ (x,y) $ denotes a point in the plotting coordinate system.

If you assume a linear scaling law.

\[ x_p(x)=\mbox{xoffset}+x\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-y\cdot\mbox{yscale} \]

you can derive:

\[ \mbox{xscale}=\frac{\mbox{plotWidth}}{\mbox{xwidth}},\ \ \ \ \  \ \mbox{xoffset}=\mbox{xPlotOffset}-\mbox{xmin}\cdot\mbox{xscale} \]

\[ \mbox{yscale}=\frac{\mbox{plotHeight}}{\mbox{ywidth}},\ \ \ \ \ \ \mbox{yoffset}=\mbox{yPlotOffset}+\mbox{ymax}\cdot\mbox{yscale} \]

If you have a logarithmic axis (i.e. we plot $ \log_b(x) $ insetad of $ x $ for a given base $ b $ ) we get the same formulas, but with $ x $ exchanged by $ \log_b(x) $. If we use the equation $ \log_b(x)=\log(x)/\log(b) $ we finally get the scaling laws:

\[ x_p(x)=\mbox{xoffset}+\frac{\log(x)}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \ \ \ \ \ \ \ \ \ y_p(y)=\mbox{yoffset}-\frac{\log(y)}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \]

From these we can calculate their parameters with the same defining equations as above:

\[ \mbox{xscale}=\frac{\mbox{plotWidth}\cdot\log(\mbox{logXAxisBase})}{\log(\mbox{xmax})-\log(\mbox{xmin})},\ \ \ \ \  \ \mbox{xoffset}=\mbox{xPlotOffset}-\frac{\log(\mbox{xmin})}{\log(\mbox{logXAxisBase})}\cdot\mbox{xscale} \]

\[ \mbox{yscale}=\frac{\mbox{plotHeight}\cdot\log(\mbox{logYAxisBase})}{\log(\mbox{ymax})-\log(\mbox{ymin})},\ \ \ \ \  \ \mbox{yoffset}=\mbox{yPlotOffset}+\frac{\log(\mbox{ymax})}{\log(\mbox{logYAxisBase})}\cdot\mbox{yscale} \]

The object implements the above coordinate transformations in the (inline) method x2p(). The inverse transformations are implemented in p2x(). They can be used to show the system coordinates of the current mouse position.

Inverted Coordinate Axes

In some cases it may be necessary to invert the direction of increasing coordinates on an axis. One such case is image analysis, as computer images usually have coordinates starting with (0,0) at the top left and increasing to the right (x) and down (y). You can invert any axis by setting setInverted(true).

See also
You can find example here: Example (JKQTPlotter): QImage as a Graph and Example (JKQTPlotter): Simple RGB image plot, showing a 3-channel OpenCV cv::Mat

Axis Ticks and Grids

This section explains how this component draws the ticks on coordinate axes and the grids that may be drawn below the plots. In principle both - grids and axes - are drawn the same way, i.e. with the same step widths. There are two types of ticks and grids: The major and the minor ticks/grids. The major ticks also show a label that denotes the value they represent. Between two major ticks the axis shows JKQTPCoordinateAxisStyle::minorTicks small ticks that are not accompanied by a label. The next image shows an example of an axis:

For the labels this class also uses an algorithm that extimates the number of valid digits (after the comma) that are needed so that two adjacent labels do not show the same text, so if you plot the range 1.10 .. 1.15 The algorithm will show at least two valid digits, as with one digit the labels would be 1.1, 1.1, 1.1, 1.1, 1.1, 1.1. With two digits they are 1.10, 1.11, 1.12, 1.13, 1.14, 1.15. The class may also use a method that can write 1m instead of 0.001 and 1k instead of 1000 (the algorithm supports the "exponent letters" f, p, n, u, m, k, M, G, T, P. The latter option may (de)activated by using showXExponentCharacter and showYExponentCharacter.

For grids applies the same. There are two grids that are drawn in different styles (often the major grid is drawn thicker and darker than the minor grid).

The minor ticks and grid lines are generated automatically, depending in the setting of JKQTPCoordinateAxisStyle::minorTicks. These properties give the number of minor ticks between two major ticks, so if the major ticks are at 1,2,3,... and you want minor ticks at 1.1, 1.2, 1.3,... then you will have to set JKQTPCoordinateAxisStyle::minorTicks=9 as there are nine ticks between two major ticks. So the minor tick spacing is calculated as:

\[ \Delta\mbox{MinorTicks}=\frac{\Delta\mbox{ticks}}{\mbox{minorTicks}+1} \]

The same applies for logarithmic axes. If the major ticks are at 1,10,100,... and you set JKQTPCoordinateAxisStyle::minorTicks=9 the program will generate 9 equally spaced minor ticks in between, so you have minor ticks at 2,3,4,...,11,12,13,... This results in a standard logarithmic axis. If you set JKQTPCoordinateAxisStyle::minorTicks=1 then you will get minor ticks at 5,15,150,...

The major tick-tick distances of linear axes may be calculated automatically in a way that the axis shows at least a given number of ticks JKQTPCoordinateAxisStyle::minTicks. The algorithm takes that tick spacing that will give a number of ticks per axis nearest but ">=" to the given JKQTPCoordinateAxisStyle::minTicks. The Algorithm is described in detail with the function calcLinearTickSpacing(). To activate this automatic tick spacing you have to set autoAxisSpacing=true.

Axis Tick Units/Scaling

In some cases it is desired to put the axis ticks not at 1,2,3,... but rather at $ 1\pi $ , $ 2\pi $ , $ 3\pi $ or any other unit than $ pi $ ,i.e.:

no axis scaling (default case)
pi-axis scaling

You can use these methods to set such a factor:

Constructor & Destructor Documentation

◆ JKQTPCoordinateAxis()

JKQTPCoordinateAxis::JKQTPCoordinateAxis ( JKQTBasePlotter parent)
explicit

class constructor

◆ ~JKQTPCoordinateAxis()

virtual JKQTPCoordinateAxis::~JKQTPCoordinateAxis ( )
virtual

class destructor

Member Function Documentation

◆ addAxisTickLabel()

void JKQTPCoordinateAxis::addAxisTickLabel ( double  x,
const QString &  label 
)

add a new tick label to the axis

◆ addAxisTickLabels() [1/4]

void JKQTPCoordinateAxis::addAxisTickLabels ( const double *  x,
const QString *  label,
int  items 
)

add a new tick label to the axis

◆ addAxisTickLabels() [2/4]

void JKQTPCoordinateAxis::addAxisTickLabels ( const double *  x,
const QStringList &  label 
)

add a new tick label to the axis

◆ addAxisTickLabels() [3/4]

void JKQTPCoordinateAxis::addAxisTickLabels ( const QVector< double > &  x,
const QString *  label 
)

add a new tick label to the axis

◆ addAxisTickLabels() [4/4]

void JKQTPCoordinateAxis::addAxisTickLabels ( const QVector< double > &  x,
const QStringList &  label 
)

add a new tick label to the axis

◆ calcLinearTickSpacing()

double JKQTPCoordinateAxis::calcLinearTickSpacing ( )
protected

calculates the tick spacing for a linear axis that spans awidth and that should show at least JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks.

The algorithm used in here works as follows:

There is only a limited subset of allowed tick distances. These distances are 1 (resulting in 10 JKQTPCoordinateAxisStyle::ticks per decade, i.e. 0,1,2,3,4,...), 2 (5 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,2,4,...), 2.5 (4 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,2.5,5,...) and 5 (2 JKQTPCoordinateAxisStyle::ticks/decade, i.e. 0,5,10,15,...). So the axis is divided into decades that each is divided into JKQTPCoordinateAxisStyle::ticks, as defined above. With these preconditions the algorithm tries to find a tick increment $ \Delta\mbox{tick} $ which is one of the above distances multiplied by a power $ \rho $ of 10. This increment is determined in a way, that the axis contains at least JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks:

\[ \Delta\mbox{tick}=f\cdot 10^\rho,\ \ \ \ \ f\in\{1, 2, 2.5, 5\} \]

  1. The algorithm starts by finding a start exponent $ \rho_s=\left\lfloor\log_{10}(\mbox{awidth})\right\rfloor+3 $. This is a good (over)estimate for the biggest possible power $ \rho $.
  2. now we set $ \rho=\rho_0 $ and $ f=10 $.
  3. now the algorithm cycles through all possible factors $ f\in\{1, 2, 2.5, 5, 10\} $ (starting from 10) and calculates $ \Delta\mbox{tick}=f\cdot 10^\rho $. Then it checks whether $ \mbox{tickcount}=\mbox{round}\left(\frac{\mbox{awidth}}{\Delta\mbox{tick}}\right) $ is smaller than JKQTPCoordinateAxisStyle::minTicks (if yes the algorithm reached its end and $ \Delta\mbox{tick} $ can be used.
  4. if $ f=1 $ is reached and checked false, then the algorithm decreases the exponent $ \rho \leftarrow \rho-1 $ and returns to step 3.

◆ calcLinearUnitDigits()

int JKQTPCoordinateAxis::calcLinearUnitDigits ( )
protected

Calculate the number of digits needed for the labels of an axis that starts at minval and where the tick spacing is tickSpacing.

This method determines how many digits to output for the labels on a coordinate axis. This is done by testing different digit numbers and comparing subsequent labels. If two labels are equal, then we need more valid digits to distinguish them.

◆ calcLogTickSpacing()

double JKQTPCoordinateAxis::calcLogTickSpacing ( )
protected

same as calcLinearTickSpacing(), but for logarithmic scaling

See also
calcLinearTickSpacing()

◆ calcPlotScaling()

void JKQTPCoordinateAxis::calcPlotScaling ( bool  force = false)

calculate the scaling and offset values from axis min/max values

This is only executed when paramChanged==true, as otherwise the data has to be still correct. recalculating may be forced by caling calcPlotScaing(true);

◆ clearAxisTickLabels()

void JKQTPCoordinateAxis::clearAxisTickLabels ( )

clear axis tick labels. This switches back to automatic labels mode for the axis.

◆ drawAxes()

virtual void JKQTPCoordinateAxis::drawAxes ( JKQTPEnhancedPainter painter,
int  move1 = 0,
int  move2 = 0 
)
pure virtual

draw the axes

Parameters
painterthe painter to use for drawing
move1offset in pixels on the major side (horizontal: bottom, vertical: left)
move2offset in pixels on the secondary side (horizontal: top, vertical: right)

Implemented in JKQTPVerticalAxisBase, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxisBase, and JKQTPHorizontalIndependentAxis.

◆ drawAxisLine()

void JKQTPCoordinateAxis::drawAxisLine ( JKQTPEnhancedPainter painter,
const QLineF &  l,
JKQTPCADrawMode  drawMode 
) const
protected

draw the axis line l (pointing from axismin to axismax) optionally decorated as specified by drawMode using JKQTPEnhancedPainter painter

◆ drawGrids()

virtual void JKQTPCoordinateAxis::drawGrids ( JKQTPEnhancedPainter painter)
pure virtual

draw grids

Implemented in JKQTPVerticalAxisBase, and JKQTPHorizontalAxisBase.

◆ floattolabel() [1/2]

QString JKQTPCoordinateAxis::floattolabel ( double  data) const

convert a float to a tick label string

◆ floattolabel() [2/2]

QString JKQTPCoordinateAxis::floattolabel ( double  data,
int  past_comma 
) const

convert a float to a tick label string with a given precision

◆ getAbsoluteMax()

double JKQTPCoordinateAxis::getAbsoluteMax ( ) const
inline

returns the current absolute max

◆ getAbsoluteMin()

double JKQTPCoordinateAxis::getAbsoluteMin ( ) const
inline

returns the current absolute min

◆ getArrowSizeFactor()

double JKQTPCoordinateAxis::getArrowSizeFactor ( ) const
inline

factor used to calculate the size of line arrows

◆ getAutoAxisSpacing()

bool JKQTPCoordinateAxis::getAutoAxisSpacing ( ) const
inline

calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

◆ getAutoLabelDigits()

bool JKQTPCoordinateAxis::getAutoLabelDigits ( ) const
inline

when true, the digits of the labels are calculated automatically

◆ getAxisColor()

QColor JKQTPCoordinateAxis::getAxisColor ( ) const
inline

color of the axis (labels, ticks, axis itself ...)

◆ getAxisLabel()

QString JKQTPCoordinateAxis::getAxisLabel ( ) const
inline

axis label of the axis

◆ getCurrentAxisStyle()

const JKQTPCoordinateAxisStyle & JKQTPCoordinateAxis::getCurrentAxisStyle ( ) const

◆ getDoUpdateScaling()

bool JKQTPCoordinateAxis::getDoUpdateScaling ( ) const
inline

can be used to switch off calcPlotScaling() temporarily, while modifying some properties

use setDoUpdateScaling() to set this property

See also
setDoUpdateScaling() and getDoUpdateScaling()

◆ getDrawGrid()

bool JKQTPCoordinateAxis::getDrawGrid ( ) const
inline

indicates whether to draw the major grid lines

◆ getDrawMinorGrid()

bool JKQTPCoordinateAxis::getDrawMinorGrid ( ) const
inline

indicates whether to draw the major grid lines

◆ getDrawMode0()

JKQTPCADrawMode JKQTPCoordinateAxis::getDrawMode0 ( ) const
inline

draw mode of the zero axis

See also
Example (JKQTPlotter): Plot With Axes through Origin

◆ getDrawMode1()

JKQTPCADrawMode JKQTPCoordinateAxis::getDrawMode1 ( ) const
inline

draw mode of the main (left/bottom) axis

◆ getDrawMode2()

JKQTPCADrawMode JKQTPCoordinateAxis::getDrawMode2 ( ) const
inline

draw mode of the secondary (right/top) axis

◆ getGridColor()

QColor JKQTPCoordinateAxis::getGridColor ( ) const
inline

color of the grid

◆ getGridStyle()

Qt::PenStyle JKQTPCoordinateAxis::getGridStyle ( ) const
inline

line stye of the grid lines

◆ getGridWidth()

double JKQTPCoordinateAxis::getGridWidth ( ) const
inline

width of the grid lines (in pixel)

◆ getInverted()

bool JKQTPCoordinateAxis::getInverted ( ) const
inline

indicates whether the axis is to be inverted or not

◆ getLabelColor()

QColor JKQTPCoordinateAxis::getLabelColor ( ) const
inline

color of the axis label

◆ getLabelDigits()

int JKQTPCoordinateAxis::getLabelDigits ( ) const
inline

digits used for tick labels

◆ getLabelDistance()

double JKQTPCoordinateAxis::getLabelDistance ( ) const
inline

distance between tick label and axis label in pt

◆ getLabelFontSize()

double JKQTPCoordinateAxis::getLabelFontSize ( ) const
inline

fontsize of the axis labels

◆ getLabelPosition()

JKQTPLabelPosition JKQTPCoordinateAxis::getLabelPosition ( ) const
inline

position of the axis label

◆ getLineWidth()

double JKQTPCoordinateAxis::getLineWidth ( ) const
inline

line width of axis in pt

◆ getLineWidthZeroAxis()

double JKQTPCoordinateAxis::getLineWidthZeroAxis ( ) const
inline

line width of 0-line in pt

◆ getLogAxis()

bool JKQTPCoordinateAxis::getLogAxis ( ) const
inline

indicates whether the y axis has a logarithmic scale

◆ getLogAxisBase()

double JKQTPCoordinateAxis::getLogAxisBase ( ) const
inline

the base for a logarithmic x axis

◆ getMax()

double JKQTPCoordinateAxis::getMax ( ) const
inline

returns the current max

◆ getMaxTickLabelSize()

QSizeF JKQTPCoordinateAxis::getMaxTickLabelSize ( JKQTPEnhancedPainter painter,
double *  ascent = nullptr,
double *  descent = nullptr 
)
protected

calculates the maximum width and height (returned as QSize) of all tick labels. Ascent and descent may also be returned in the two additional pointer arguments-

◆ getMin()

double JKQTPCoordinateAxis::getMin ( ) const
inline

returns the current min

◆ getMinorGridColor()

QColor JKQTPCoordinateAxis::getMinorGridColor ( ) const
inline

color of the grid

◆ getMinorGridStyle()

Qt::PenStyle JKQTPCoordinateAxis::getMinorGridStyle ( ) const
inline

line stye of the grid lines

◆ getMinorGridWidth()

double JKQTPCoordinateAxis::getMinorGridWidth ( ) const
inline

width of the grid lines (in pixel)

◆ getMinorTickColor()

QColor JKQTPCoordinateAxis::getMinorTickColor ( ) const
inline

color of minor ticks

◆ getMinorTickLabelColor()

QColor JKQTPCoordinateAxis::getMinorTickLabelColor ( ) const
inline

color of minor tick labels

◆ getMinorTickLabelFontSize()

double JKQTPCoordinateAxis::getMinorTickLabelFontSize ( ) const
inline

fontsize of the minor axis tick labels

◆ getMinorTickLabelFullNumber()

bool JKQTPCoordinateAxis::getMinorTickLabelFullNumber ( ) const
inline

indicates whether the minor tick labels should be full numbers, or just a number between 0..10

◆ getMinorTickLabelsEnabled()

bool JKQTPCoordinateAxis::getMinorTickLabelsEnabled ( ) const
inline

if true, the plotter displays minor axis labels as number between 1 and 10 in some cases

◆ getMinorTickOutsideLength()

double JKQTPCoordinateAxis::getMinorTickOutsideLength ( ) const
inline

length of a minor axis tick outside the plot border in pt

◆ getMinorTicks()

unsigned int JKQTPCoordinateAxis::getMinorTicks ( ) const
inline

number of minor grid lines per (major) axis tick interval

◆ getMinorTickWidth()

double JKQTPCoordinateAxis::getMinorTickWidth ( ) const
inline

line width of minor ticks in pt

◆ getMinTicks()

unsigned int JKQTPCoordinateAxis::getMinTicks ( ) const
inline

minimum number of axis ticks

◆ getNextLabel()

bool JKQTPCoordinateAxis::getNextLabel ( double &  x,
QString &  label,
bool  init = false 
)
protected

calculates the next label from the given parameters.

Returns
true on success and false if there is no more label
Parameters
xbefore call: the position of the label for which the text should be returned (or JKQTPCoordinateAxisStyle::tickStart for first call), after call: position of the next label (given in world coordinates!)
labelafter call: text of the (input) tick label This is an empty string, if the label is not visible!
initcall this function with init=true to obtain the first label (at JKQTPCoordinateAxisStyle::tickStart)

◆ getNextLabelDistance()

double JKQTPCoordinateAxis::getNextLabelDistance ( double  x)
protected

returns the distance from the current tick position (x before call) to the next tick position

◆ getParent() [1/2]

JKQTBasePlotter * JKQTPCoordinateAxis::getParent ( )
inline

parent plotter class

◆ getParent() [2/2]

const JKQTBasePlotter * JKQTPCoordinateAxis::getParent ( ) const
inline

parent plotter class

◆ getParentMathText() [1/2]

JKQTMathText * JKQTPCoordinateAxis::getParentMathText ( )
protected

retun parents JKQTMathText* object

◆ getParentMathText() [2/2]

const JKQTMathText * JKQTPCoordinateAxis::getParentMathText ( ) const
protected

retun parents JKQTMathText* object

◆ getParentOtheraxisInverted()

virtual bool JKQTPCoordinateAxis::getParentOtheraxisInverted ( ) const
pure virtual

is other (perpendicular) axis inverted (needed for grids)

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ getParentOtheraxisOffset()

virtual double JKQTPCoordinateAxis::getParentOtheraxisOffset ( ) const
pure virtual

pixel offset of (perpendicular) other axis (needed for grids)

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ getParentOtheraxisWidth()

virtual double JKQTPCoordinateAxis::getParentOtheraxisWidth ( ) const
pure virtual

width of other (perpendicular) axis (needed for grids)

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ getParentPlotOffset()

virtual double JKQTPCoordinateAxis::getParentPlotOffset ( ) const
pure virtual

offset of the plot in the direction of the axis

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ getParentPlotWidth()

virtual double JKQTPCoordinateAxis::getParentPlotWidth ( ) const
pure virtual

width of the plot in the direction of the axis

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ getShowZeroAxis()

bool JKQTPCoordinateAxis::getShowZeroAxis ( ) const
inline

indicates whether to draw a thick axis line at x=0 (zero axis)

◆ getSize0()

virtual Axis0ElementsSizeDescription JKQTPCoordinateAxis::getSize0 ( JKQTPEnhancedPainter painter)
protectedvirtual

returns the size of the zero axis in pixels, the first part of the return-value is the lhs size and the second part the rhs size

Reimplemented in JKQTPVerticalAxisBase, and JKQTPHorizontalAxisBase.

◆ getSize1()

virtual AxisElementsSizeDescription JKQTPCoordinateAxis::getSize1 ( JKQTPEnhancedPainter painter)
pure virtual

returns the sizerequirement of the left/bottom axis in pixels

Parameters
paintera JKQTPEnhancedPainter to use for determining sizes (the same that would be used for drawing!)
Returns
size of the additional space outside the plot rectangle, required for the axis.

Implemented in JKQTPVerticalAxisBase, and JKQTPHorizontalAxisBase.

◆ getSize2()

virtual AxisElementsSizeDescription JKQTPCoordinateAxis::getSize2 ( JKQTPEnhancedPainter painter)
pure virtual

returns the size of the right/top axis in pixels

Parameters
paintera JKQTPEnhancedPainter to use for determining sizes (the same that would be used for drawing!)
Returns
size of the additional space outside the plot rectangle, required for the axis.

Implemented in JKQTPVerticalAxisBase, and JKQTPHorizontalAxisBase.

◆ getTickColor()

QColor JKQTPCoordinateAxis::getTickColor ( ) const
inline

color of axis ticks

◆ getTickDateFormat()

QString JKQTPCoordinateAxis::getTickDateFormat ( ) const
inline

format string for date tick labels, see QDateTime::toString() documentation for details on format strings

◆ getTickDateTimeFormat()

QString JKQTPCoordinateAxis::getTickDateTimeFormat ( ) const
inline

format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings

◆ getTickFormatfFormat()

QString JKQTPCoordinateAxis::getTickFormatfFormat ( ) const
inline

format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification ). The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "\\texttt{{ y={:*^+8.1f}}}":

Note
This option is only available for C++20 and above, use the CMake option JKQtPlotter_ENABLED_CXX20=ON if your compiler supports this.

◆ getTickLabelAngle()

double JKQTPCoordinateAxis::getTickLabelAngle ( ) const
inline

rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)

These images show some example rotations:

◆ getTickLabelColor()

QColor JKQTPCoordinateAxis::getTickLabelColor ( ) const
inline

color of axis tick labels

◆ getTickLabelDistance()

double JKQTPCoordinateAxis::getTickLabelDistance ( ) const
inline

distance between tick end and label start in pt

◆ getTickLabelFontSize()

double JKQTPCoordinateAxis::getTickLabelFontSize ( ) const
inline

fontsize of the axis tick labels

◆ getTickLabelType()

JKQTPCALabelType JKQTPCoordinateAxis::getTickLabelType ( ) const
inline

indicates how to draw the labels

◆ getTickMode()

JKQTPLabelTickMode JKQTPCoordinateAxis::getTickMode ( ) const
inline

mode of the major ticks

◆ getTickOutsideLength()

double JKQTPCoordinateAxis::getTickOutsideLength ( ) const
inline

length of an axis tick outside the plot border in pt

◆ getTickPrintfFormat()

QString JKQTPCoordinateAxis::getTickPrintfFormat ( ) const
inline

format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string documentation for details on format strings The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "y=%+.2f":

◆ getTickSpacing()

double JKQTPCoordinateAxis::getTickSpacing ( ) const
inline

calculated property: axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes.

See also
calcPlotScaling(), calcTickSpacing()

◆ getTickTimeFormat()

QString JKQTPCoordinateAxis::getTickTimeFormat ( ) const
inline

format string for time tick labels, see QDateTime::toString() documentation for details on format strings

◆ getTickUnitFactor()

double JKQTPCoordinateAxis::getTickUnitFactor ( ) const
inline

tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)

◆ getTickUnitName()

QString JKQTPCoordinateAxis::getTickUnitName ( ) const
inline

name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...

◆ getTickWidth()

double JKQTPCoordinateAxis::getTickWidth ( ) const
inline

line width of ticks in pt

◆ getUserLogTickSpacing()

double JKQTPCoordinateAxis::getUserLogTickSpacing ( ) const
inline

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ getUserTickSpacing()

double JKQTPCoordinateAxis::getUserTickSpacing ( ) const
inline

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ getZeroAxisPos()

double JKQTPCoordinateAxis::getZeroAxisPos ( bool *  drawZeroAxis = nullptr)
protected

calculate the position of the zero-axis (and whether to draw it or not)

◆ isAxisRangeFixed()

bool JKQTPCoordinateAxis::isAxisRangeFixed ( ) const
inline

returns whether the axis range is fixed, i.e. may not change!

◆ isLinearAxis()

bool JKQTPCoordinateAxis::isLinearAxis ( ) const

returns whether this axis uses linear scaling (is false e.g. for isLogAxis()==true)

◆ isLogAxis()

bool JKQTPCoordinateAxis::isLogAxis ( ) const

returns whether this axis uses logarithmic scaling

◆ isSecondaryAxis()

virtual bool JKQTPCoordinateAxis::isSecondaryAxis ( ) const
protectedvirtual

figures out (possibly by probing the parent JKQTBasePlotter), whether this axis is a secondary axis

◆ loadCurrentAxisStyle()

void JKQTPCoordinateAxis::loadCurrentAxisStyle ( const QSettings &  settings,
const QString &  group = "plot/axes/" 
)

replace the current style properties for this JKQTBasePlotter with properties loaded from settings

Parameters
settingsthe QSettings object to read from
groupgroup in settings to read from
See also
JKQTPCoordinateAxisStyle getCurrentAxisStyle(), Styling System

◆ loadSettings()

virtual void JKQTPCoordinateAxis::loadSettings ( const QSettings &  settings,
const QString &  group = QString("plots/axes/") 
)
virtual

loads the plot properties from a QSettings object

◆ p2x()

double JKQTPCoordinateAxis::p2x ( double  x) const
inline

return x coordinate from x-pixel

◆ parentOtherAxisX2P()

virtual double JKQTPCoordinateAxis::parentOtherAxisX2P ( double  x) const
pure virtual

calls x2p() of the other axis (or returns NAN if the other axis does not exist

Implemented in JKQTPVerticalAxis, JKQTPVerticalIndependentAxis, JKQTPHorizontalAxis, and JKQTPHorizontalIndependentAxis.

◆ redrawPlot()

void JKQTPCoordinateAxis::redrawPlot ( )
protected

simply calls the redrawPlot method of the parent plotter class

◆ resetTickUnit

void JKQTPCoordinateAxis::resetTickUnit ( )
slot

resets tickUnitFactor and tickUnitName in one call

See also
calls setTickUnit(), setTickUnitName() and setTickUnitFactor()

◆ saveCurrentAxisStyle()

void JKQTPCoordinateAxis::saveCurrentAxisStyle ( QSettings &  settings,
const QString &  group = "plot/axes/" 
) const

store the current style properties for this JKQTBasePlotter with properties loaded from settings

Parameters
settingsthe QSettings object to write to
groupgroup in settings to write to
See also
JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), setCurrentAxisStyle(), getCurrentAxisStyle(), Styling System

◆ saveSettings()

virtual void JKQTPCoordinateAxis::saveSettings ( QSettings &  settings,
const QString &  group = QString("plots/axes/") 
) const
virtual

saves the plot properties into a QSettings object.

This method only saves those properties that differ from their default value.

◆ setAbsoluteRange

void JKQTPCoordinateAxis::setAbsoluteRange ( double  aamin,
double  aamax 
)
slot

sets absolutely limiting range of the plot

The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function.

Parameters
aaminabsolute minimum of the axis
aamaxabsolute maximum of the axis
Note
if the aspect ratio (set in the JKQTBasePlotter or JKQTPlotter) of this does not fit into the widget, it is possible that you don't see the complete contents!
See also
setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTPCoordinateAxis::setAbsoluteRange()

◆ setArrowSizeFactor

void JKQTPCoordinateAxis::setArrowSizeFactor ( double  f)
slot

factor used to calculate the size of line arrows

◆ setAutoAxisSpacing

void JKQTPCoordinateAxis::setAutoAxisSpacing ( bool  __value)
slot

calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

◆ setAutoLabelDigits()

void JKQTPCoordinateAxis::setAutoLabelDigits ( bool  __value)
inline

when true, the digits of the labels are calculated automatically

◆ setAxisColor

void JKQTPCoordinateAxis::setAxisColor ( const QColor &  __value)
slot

color of the axis (labels, ticks, axis itself ...)

◆ setAxisLabel

void JKQTPCoordinateAxis::setAxisLabel ( const QString &  __value)
slot

axis label of the axis

◆ setAxisMinWidth

void JKQTPCoordinateAxis::setAxisMinWidth ( double  __value)
slot

absolute minimum range width, feature switched off when <0

◆ setColor

void JKQTPCoordinateAxis::setColor ( QColor  c)
slot

sets all colors (line, ticks, label, ...) of the axis

◆ setCurrentAxisStyle()

void JKQTPCoordinateAxis::setCurrentAxisStyle ( const JKQTPCoordinateAxisStyle style)

◆ setDoUpdateScaling()

void JKQTPCoordinateAxis::setDoUpdateScaling ( bool  __value)
inline

can be used to switch off calcPlotScaling() temporarily, while modifying some properties

use setDoUpdateScaling() to set this property

See also
setDoUpdateScaling() and getDoUpdateScaling()

◆ setDrawGrid

void JKQTPCoordinateAxis::setDrawGrid ( bool  __value)
slot

indicates whether to draw the major grid lines

◆ setDrawMinorGrid

void JKQTPCoordinateAxis::setDrawMinorGrid ( bool  __value)
slot

indicates whether to draw the major grid lines

◆ setDrawMode0

void JKQTPCoordinateAxis::setDrawMode0 ( JKQTPCADrawMode  __value)
slot

draw mode of the zero axis

See also
Example (JKQTPlotter): Plot With Axes through Origin

◆ setDrawMode1

void JKQTPCoordinateAxis::setDrawMode1 ( JKQTPCADrawMode  __value)
slot

draw mode of the main (left/bottom) axis

◆ setDrawMode2

void JKQTPCoordinateAxis::setDrawMode2 ( JKQTPCADrawMode  __value)
slot

draw mode of the secondary (right/top) axis

◆ setGridColor [1/2]

void JKQTPCoordinateAxis::setGridColor ( const QColor &  __value)
slot

color of the grid

◆ setGridColor [2/2]

void JKQTPCoordinateAxis::setGridColor ( const QColor &  __value,
double  alpha 
)
slot

color of the grid

◆ setGridStyle

void JKQTPCoordinateAxis::setGridStyle ( Qt::PenStyle  __value)
slot

line stye of the grid lines

◆ setGridWidth

void JKQTPCoordinateAxis::setGridWidth ( double  __value)
slot

width of the grid lines (in pixel)

◆ setInverted

void JKQTPCoordinateAxis::setInverted ( bool  __value)
slot

indicates whether the axis is to be inverted or not

◆ setLabelColor

void JKQTPCoordinateAxis::setLabelColor ( QColor  c)
slot

color of the axis label

◆ setLabelDigits

void JKQTPCoordinateAxis::setLabelDigits ( int  __value)
slot

digits used for tick labels

◆ setLabelDistance

void JKQTPCoordinateAxis::setLabelDistance ( double  __value)
slot

distance between tick label and axis label in pt

◆ setLabelFontSize

void JKQTPCoordinateAxis::setLabelFontSize ( double  __value)
slot

fontsize of the axis labels

◆ setLabelPosition

void JKQTPCoordinateAxis::setLabelPosition ( JKQTPLabelPosition  __value)
slot

position of the axis label

◆ setLineWidth

void JKQTPCoordinateAxis::setLineWidth ( double  __value)
slot

line width of axis in pt

◆ setLineWidthZeroAxis

void JKQTPCoordinateAxis::setLineWidthZeroAxis ( double  __value)
slot

line width of 0-line in pt

◆ setLogAxis

void JKQTPCoordinateAxis::setLogAxis ( bool  __value)
slot

indicates whether the y axis has a logarithmic scale

◆ setLogAxisBase

void JKQTPCoordinateAxis::setLogAxisBase ( double  __value)
slot

the base for a logarithmic x axis

◆ setMax

void JKQTPCoordinateAxis::setMax ( double  amax)
slot

set axis minimum range of plot axis

Parameters
amaxnew maximum
Note
the actually set range may differ from [getMin()...amax] in order to fullfill requirements e.g. for logarithmic axes or an absolute axis range (see setAbsoluteRange() )
if setRangeFixed(true) was called before this call, the axis range is fixed and this function has NO EFFECT!

◆ setMin

void JKQTPCoordinateAxis::setMin ( double  amin)
slot

set axis minimum range of plot axis

Parameters
aminnew minimum
Note
the actually set range may differ from [amin...getMax()] in order to fullfill requirements e.g. for logarithmic axes or an absolute axis range (see setAbsoluteRange() )
if setRangeFixed(true) was called before this call, the axis range is fixed and this function has NO EFFECT!

◆ setMinorGridColor [1/2]

void JKQTPCoordinateAxis::setMinorGridColor ( const QColor &  __value)
slot

color of the grid

◆ setMinorGridColor [2/2]

void JKQTPCoordinateAxis::setMinorGridColor ( const QColor &  __value,
double  alpha 
)
slot

color of the grid

◆ setMinorGridStyle

void JKQTPCoordinateAxis::setMinorGridStyle ( Qt::PenStyle  __value)
slot

line stye of the grid lines

◆ setMinorGridWidth

void JKQTPCoordinateAxis::setMinorGridWidth ( double  __value)
slot

width of the grid lines (in pixel)

◆ setMinorTickColor

void JKQTPCoordinateAxis::setMinorTickColor ( QColor  c)
slot

color of minor ticks

◆ setMinorTickInsideLength

void JKQTPCoordinateAxis::setMinorTickInsideLength ( double  __value)
slot

length of a minor axis tick inside the plot border in pt

◆ setMinorTickLabelColor

void JKQTPCoordinateAxis::setMinorTickLabelColor ( QColor  c)
slot

color of minor tick labels

◆ setMinorTickLabelFontSize

void JKQTPCoordinateAxis::setMinorTickLabelFontSize ( double  __value)
slot

fontsize of the minor axis tick labels

◆ setMinorTickLabelFullNumber

void JKQTPCoordinateAxis::setMinorTickLabelFullNumber ( bool  __value)
slot

indicates whether the minor tick labels should be full numbers, or just a number between 0..10

◆ setMinorTickLabelsEnabled

void JKQTPCoordinateAxis::setMinorTickLabelsEnabled ( bool  __value)
slot

if true, the plotter displays minor axis labels as number between 1 and 10 in some cases

◆ setMinorTickOutsideLength

void JKQTPCoordinateAxis::setMinorTickOutsideLength ( double  __value)
slot

length of a minor axis tick outside the plot border in pt

◆ setMinorTicks [1/2]

void JKQTPCoordinateAxis::setMinorTicks ( int  __value)
slot

number of minor grid lines per (major) axis tick interval

◆ setMinorTicks [2/2]

void JKQTPCoordinateAxis::setMinorTicks ( unsigned int  __value)
slot

number of minor grid lines per (major) axis tick interval

◆ setMinorTickWidth

void JKQTPCoordinateAxis::setMinorTickWidth ( double  __value)
slot

line width of minor ticks in pt

◆ setMinTicks

void JKQTPCoordinateAxis::setMinTicks ( unsigned int  __value)
slot

minimum number of axis ticks

◆ setNoAbsoluteRange

void JKQTPCoordinateAxis::setNoAbsoluteRange ( )
slot

do not use an absolute range of plot axis

◆ setParent()

virtual void JKQTPCoordinateAxis::setParent ( JKQTBasePlotter parent)
virtual

◆ setRange

void JKQTPCoordinateAxis::setRange ( double  amin,
double  amax 
)
slot

set range of plot axis

Parameters
aminnew minimum
amaxnew maximum
Note
the actually set range may differ from [amin...amax] in order to fullfill requirements e.g. for logarithmic axes or an absolute axis range (see setAbsoluteRange() )
if setRangeFixed(true) was called before this call, the axis range is fixed and this function has NO EFFECT!

◆ setRangeFixed

void JKQTPCoordinateAxis::setRangeFixed ( bool  fixed)
slot

fixes/ufixes the axis

a fixed axis's range (minimum/maximum) may not be changed by the user!)

◆ setShowZeroAxis

void JKQTPCoordinateAxis::setShowZeroAxis ( bool  __value)
slot

indicates whether to draw a thick axis line at x=0 (zero axis)

◆ setTickColor

void JKQTPCoordinateAxis::setTickColor ( QColor  c)
slot

color of axis ticks

◆ setTickDateFormat

void JKQTPCoordinateAxis::setTickDateFormat ( const QString &  __value)
slot

format string for date tick labels, see QDateTime::toString() documentation for details on format strings

◆ setTickDateTimeFormat

void JKQTPCoordinateAxis::setTickDateTimeFormat ( const QString &  __value)
slot

format string for datetime tick labels, see QDateTime::toString() documentation for details on format strings

◆ setTickFormatFormat

void JKQTPCoordinateAxis::setTickFormatFormat ( const QString &  __value)
slot

format string for std::format tick labels, (see e.g. https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification ). The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "\\texttt{{ y={:*^+8.1f}}}":

Note
This option is only available for C++20 and above, use the CMake option JKQtPlotter_ENABLED_CXX20=ON if your compiler supports this.

◆ setTickInsideLength

void JKQTPCoordinateAxis::setTickInsideLength ( double  __value)
slot

length of an axis tick inside the plot border in pt

◆ setTickLabelAngle

void JKQTPCoordinateAxis::setTickLabelAngle ( double  __value)
slot

rotation angle of tick labels [-180..180], i.e. given in degrees, default is 0 (horizontal)

These images show some example rotations:

◆ setTickLabelColor

void JKQTPCoordinateAxis::setTickLabelColor ( QColor  c)
slot

color of axis tick labels

◆ setTickLabelDistance

void JKQTPCoordinateAxis::setTickLabelDistance ( double  __value)
slot

distance between tick end and label start in pt

◆ setTickLabelFontSize

void JKQTPCoordinateAxis::setTickLabelFontSize ( double  __value)
slot

fontsize of the axis tick labels

◆ setTickLabelType

void JKQTPCoordinateAxis::setTickLabelType ( JKQTPCALabelType  __value)
slot

indicates how to draw the labels

◆ setTickMode [1/2]

void JKQTPCoordinateAxis::setTickMode ( int  __value)
slot

mode of the major ticks

◆ setTickMode [2/2]

void JKQTPCoordinateAxis::setTickMode ( JKQTPLabelTickMode  __value)
slot

mode of the major ticks

◆ setTickOutsideLength

void JKQTPCoordinateAxis::setTickOutsideLength ( double  __value)
slot

length of an axis tick outside the plot border in pt

◆ setTickPrintfFormat

void JKQTPCoordinateAxis::setTickPrintfFormat ( const QString &  __value)
slot

format string for printf tick labels, see https://en.wikipedia.org/wiki/Printf_format_string documentation for details on format strings The first data parameter is the tick value as double an the second is tickUnitName as string. The following image shows an example for "y=%+.2f":

◆ setTickTimeFormat

void JKQTPCoordinateAxis::setTickTimeFormat ( const QString &  __value)
slot

format string for time tick labels, see QDateTime::toString() documentation for details on format strings

◆ setTickUnit

void JKQTPCoordinateAxis::setTickUnit ( double  factor,
const QString &  name 
)
slot

sets tickUnitFactor and tickUnitName in one call

See also
calls setTickUnitName() and setTickUnitFactor()

◆ setTickUnitFactor

void JKQTPCoordinateAxis::setTickUnitFactor ( double  __value)
slot

tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)

◆ setTickUnitName

void JKQTPCoordinateAxis::setTickUnitName ( const QString &  __value)
slot

name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...

◆ setTickUnitPi

void JKQTPCoordinateAxis::setTickUnitPi ( )
slot

sets pi-scaling for tickUnitFactor and tickUnitName in one call

See also
calls setTickUnitName() and setTickUnitFactor()

◆ setTickWidth

void JKQTPCoordinateAxis::setTickWidth ( double  __value)
slot

line width of ticks in pt

◆ setUserLogTickSpacing

void JKQTPCoordinateAxis::setUserLogTickSpacing ( double  __value)
slot

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ setUserTickSpacing

void JKQTPCoordinateAxis::setUserTickSpacing ( double  __value)
slot

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ x2p()

double JKQTPCoordinateAxis::x2p ( double  x) const
inline

return x-pixel coordinate from x coordinate

Member Data Documentation

◆ autoAxisSpacing

bool JKQTPCoordinateAxis::autoAxisSpacing
protected

calculated property: indicates whether the object should use automatic tick spacing for the x axis (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

◆ axisabsoultemax

double JKQTPCoordinateAxis::axisabsoultemax
protected

absoulte maximum of axis (axismin/axismax xan not be set above this)

◆ axisabsoultemin

double JKQTPCoordinateAxis::axisabsoultemin
protected

absoulte minimum of axis (axismin/axismax xan not be set below this)

◆ axisLabel

QString JKQTPCoordinateAxis::axisLabel
protected

axis label of the axis

◆ axismax

double JKQTPCoordinateAxis::axismax
protected

current view: maximum of axis

◆ axismin

double JKQTPCoordinateAxis::axismin
protected

current view: minimum of axis

◆ axisMinWidth

double JKQTPCoordinateAxis::axisMinWidth
protected

absolute minimum range width, feature switched off when <0

◆ axisPrefix

QString JKQTPCoordinateAxis::axisPrefix
protected

axis prefix for storage of parameters

◆ axisRangeFixed

bool JKQTPCoordinateAxis::axisRangeFixed
protected

indicates whether this axis is fixed, i.e. axismin and axismax are frozen to their current values

◆ axisStyle

JKQTPCoordinateAxisStyle JKQTPCoordinateAxis::axisStyle
protected

◆ doUpdateScaling

bool JKQTPCoordinateAxis::doUpdateScaling
protected

can be used to switch off calcPlotScaling() temporarily, while modifying some properties

use setDoUpdateScaling() to set this property

See also
setDoUpdateScaling() and getDoUpdateScaling()

◆ inverted

bool JKQTPCoordinateAxis::inverted
protected

indicates whether the axis is to be inverted or not

◆ logAxis

bool JKQTPCoordinateAxis::logAxis
protected

indicates whether the y axis has a logarithmic scale

◆ logAxisBase

double JKQTPCoordinateAxis::logAxisBase
protected

the base for a logarithmic x axis

◆ offset

double JKQTPCoordinateAxis::offset
protected

calculated property: axis offset (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

◆ paramsChanged

bool JKQTPCoordinateAxis::paramsChanged
protected

indicates whether one of the parameters has changed sinse the last recalculation of tickSpacing ...

◆ parent

JKQTBasePlotter* JKQTPCoordinateAxis::parent
protected

parent plotter class

◆ scale

double JKQTPCoordinateAxis::scale
protected

calculated property: axis scaling factor (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

◆ scaleSign

double JKQTPCoordinateAxis::scaleSign
protected

this is used by x2p() and p2x() to determine the sign

◆ tickLabels

QVector<QPair<double, QString> > JKQTPCoordinateAxis::tickLabels
protected

a list of tick labels.

If this list contains items, this class will NOT plot a standard x-axis, but only mark the positions in this list. Every item is a x-position together with the label to be plotted there. The label may contain LaTeX markup.

◆ tickSpacing

double JKQTPCoordinateAxis::tickSpacing
protected

calculated property: axis tick spacing (calculated by calcPlotScaling() and calcTickSpacing() ) for logarithmic/linear axes.

See also
calcPlotScaling(), calcTickSpacing()

◆ tickSpacingLog

double JKQTPCoordinateAxis::tickSpacingLog
protected

calculated property: axis tick spacing for logarithmic JKQTPCoordinateAxisStyle::ticks (calculated by calcPlotScaling() and calcTickSpacing() ) axes.

See also
calcPlotScaling()

◆ tickStart

double JKQTPCoordinateAxis::tickStart
protected

calculated property: x position of the first tick (calculated by calcPlotScaling() ). Given in system coordinates, not pixel coordinates.

See also
calcPlotScaling(), calcTickSpacing()

◆ tickUnitFactor

double JKQTPCoordinateAxis::tickUnitFactor
protected

tick values are the actual x/y-coordiniate, divided by this value (e.g. pu $ \pi $ to have an axis with values 0, pi, 2pi, 3pi ...)

◆ tickUnitName

QString JKQTPCoordinateAxis::tickUnitName
protected

name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. "2pi" instead of 6.28...

◆ userLogTickSpacing

double JKQTPCoordinateAxis::userLogTickSpacing
protected

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ userTickSpacing

double JKQTPCoordinateAxis::userTickSpacing
protected

if autoXAxisSpacing is false then this value is used for xTickSpacing. So this is the property which is editable by use of public access methods.

◆ width

double JKQTPCoordinateAxis::width
protected

calculated property: width of plot on axis (calculated by calcPlotScaling() )

See also
calcPlotScaling(), calcTickSpacing()

The documentation for this class was generated from the following file: