QCPAxisTickerLog

Search for usage in LXR

Inheritance diagram for QCPAxisTickerLog:

Public Member Functions

 QCPAxisTickerLog ()
 
double logBase () const
 
void setLogBase (double base)
 
void setSubTickCount (int subTicks)
 
int subTickCount () const
 
- Public Member Functions inherited from QCPAxisTicker
 QCPAxisTicker ()
 
virtual void generate (const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)
 
void setTickCount (int count)
 
void setTickOrigin (double origin)
 
void setTickStepStrategy (TickStepStrategy strategy)
 
int tickCount () const
 
double tickOrigin () const
 
TickStepStrategy tickStepStrategy () const
 

Protected Member Functions

virtual QVector< double > createTickVector (double tickStep, const QCPRange &range) override
 
virtual int getSubTickCount (double tickStep) override
 
- Protected Member Functions inherited from QCPAxisTicker
double cleanMantissa (double input) const
 
virtual QVector< QStringcreateLabelVector (const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision)
 
virtual QVector< double > createSubTickVector (int subTickCount, const QVector< double > &ticks)
 
double getMantissa (double input, double *magnitude=nullptr) const
 
virtual QString getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision)
 
virtual double getTickStep (const QCPRange &range)
 
double pickClosest (double target, const QVector< double > &candidates) const
 
void trimTicks (const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const
 

Protected Attributes

double mLogBase
 
double mLogBaseLnInv
 
int mSubTickCount
 
- Protected Attributes inherited from QCPAxisTicker
int mTickCount
 
double mTickOrigin
 
TickStepStrategy mTickStepStrategy
 

Additional Inherited Members

- Public Types inherited from QCPAxisTicker
enum  TickStepStrategy { tssReadability , tssMeetTickCount }
 

Detailed Description

Specialized axis ticker suited for logarithmic axes.

This QCPAxisTicker subclass generates ticks with unequal tick intervals suited for logarithmic axis scales. The ticks are placed at powers of the specified log base (setLogBase).

Especially in the case of a log base equal to 10 (the default), it might be desirable to have tick labels in the form of powers of ten without mantissa display. To achieve this, set the number precision (QCPAxis::setNumberPrecision) to zero and the number format (QCPAxis::setNumberFormat) to scientific (exponential) display with beautifully typeset decimal powers, so a format string of "eb". This will result in the following axis tick labels:

The ticker can be created and assigned to an axis like this:

Note that the nature of logarithmic ticks imply that there exists a smallest possible tick step, corresponding to one multiplication by the log base. If the user zooms in further than that, no new ticks would appear, leading to very sparse or even no axis ticks on the axis. To prevent this situation, this ticker falls back to regular tick generation if the axis range would be covered by too few logarithmically placed ticks.

Definition at line 1980 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAxisTickerLog()

QCPAxisTickerLog::QCPAxisTickerLog ( )

Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.

Definition at line 7712 of file qcustomplot.cpp.

Member Function Documentation

◆ createTickVector()

QVector< double > QCPAxisTickerLog::createTickVector ( double tickStep,
const QCPRange & range )
overrideprotectedvirtual

Creates ticks with a spacing given by the logarithm base and an increasing integer power in the provided range. The step in which the power increases tick by tick is chosen in order to keep the total number of ticks as close as possible to the tick count (setTickCount).

The parameter tickStep is ignored for the normal logarithmic ticker generation. Only when zoomed in very far such that not enough logarithmically placed ticks would be visible, this function falls back to the regular QCPAxisTicker::createTickVector, which then uses tickStep.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7776 of file qcustomplot.cpp.

◆ getSubTickCount()

int QCPAxisTickerLog::getSubTickCount ( double tickStep)
overrideprotectedvirtual

Returns the sub tick count specified in setSubTickCount. For QCPAxisTickerLog, there is no automatic sub tick count calculation necessary.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7758 of file qcustomplot.cpp.

◆ logBase()

double QCPAxisTickerLog::logBase ( ) const
inline

Definition at line 1986 of file qcustomplot.h.

◆ setLogBase()

void QCPAxisTickerLog::setLogBase ( double base)

Sets the logarithm base used for tick coordinate generation. The ticks will be placed at integer powers of base.

Definition at line 7723 of file qcustomplot.cpp.

◆ setSubTickCount()

void QCPAxisTickerLog::setSubTickCount ( int subTicks)

Sets the number of sub ticks in a tick interval. Within each interval, the sub ticks are spaced linearly to provide a better visual guide, so the sub tick density increases toward the higher tick.

Note that subTicks is the number of sub ticks (not sub intervals) in one tick interval. So in the case of logarithm base 10 an intuitive sub tick spacing would be achieved with eight sub ticks (the default). This means e.g. between the ticks 10 and 100 there will be eight ticks, namely at 20, 30, 40, 50, 60, 70, 80 and 90.

Definition at line 7743 of file qcustomplot.cpp.

◆ subTickCount()

int QCPAxisTickerLog::subTickCount ( ) const
inline

Definition at line 1987 of file qcustomplot.h.

Member Data Documentation

◆ mLogBase

double QCPAxisTickerLog::mLogBase
protected

Definition at line 1995 of file qcustomplot.h.

◆ mLogBaseLnInv

double QCPAxisTickerLog::mLogBaseLnInv
protected

Definition at line 1999 of file qcustomplot.h.

◆ mSubTickCount

int QCPAxisTickerLog::mSubTickCount
protected

Definition at line 1996 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.