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 2037 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 7730 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 7794 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 7776 of file qcustomplot.cpp.

◆ logBase()

double QCPAxisTickerLog::logBase ( ) const
inline

Definition at line 2043 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 7741 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 7761 of file qcustomplot.cpp.

◆ subTickCount()

int QCPAxisTickerLog::subTickCount ( ) const
inline

Definition at line 2044 of file qcustomplot.h.

Member Data Documentation

◆ mLogBase

double QCPAxisTickerLog::mLogBase
protected

Definition at line 2052 of file qcustomplot.h.

◆ mLogBaseLnInv

double QCPAxisTickerLog::mLogBaseLnInv
protected

Definition at line 2056 of file qcustomplot.h.

◆ mSubTickCount

int QCPAxisTickerLog::mSubTickCount
protected

Definition at line 2053 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 Fri Nov 29 2024 11:57:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.