Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPAxis Class Reference

Manages a single axis inside a QCustomPlot. More...

#include <plot2d.h>

Inheritance diagram for QCPAxis:
QCPLayerable

Public Types

enum  AxisType { atLeft, atRight, atTop, atBottom }
 
enum  LabelType { ltNumber, ltDateTime }
 
enum  ScaleType { stLinear, stLogarithmic }
 
enum  SelectablePart { spNone = 0, spAxis = 0x001, spTickLabels = 0x002, spAxisLabel = 0x004 }
 

Public Slots

void setRange (const QCPRange &range)
 
void setSelectable (const QCPAxis::SelectableParts &selectable)
 
void setSelected (const QCPAxis::SelectableParts &selected)
 

Signals

void ticksRequest ()
 
void rangeChanged (const QCPRange &newRange)
 
void selectionChanged (QCPAxis::SelectableParts selection)
 

Public Member Functions

 QCPAxis (QCustomPlot *parentPlot, AxisType type)
 
virtual ~QCPAxis ()
 
AxisType axisType () const
 
QRect axisRect () const
 
ScaleType scaleType () const
 
double scaleLogBase () const
 
const QCPRange range () const
 
bool rangeReversed () const
 
bool antialiasedGrid () const
 
bool antialiasedSubGrid () const
 
bool antialiasedZeroLine () const
 
bool grid () const
 
bool subGrid () const
 
bool autoTicks () const
 
int autoTickCount () const
 
bool autoTickLabels () const
 
bool autoTickStep () const
 
bool autoSubTicks () const
 
bool ticks () const
 
bool tickLabels () const
 
int tickLabelPadding () const
 
LabelType tickLabelType () const
 
QFont tickLabelFont () const
 
QColor tickLabelColor () const
 
double tickLabelRotation () const
 
QString dateTimeFormat () const
 
QString numberFormat () const
 
int numberPrecision () const
 
double tickStep () const
 
QVector< double > tickVector () const
 
QVector< QString > tickVectorLabels () const
 
int tickLengthIn () const
 
int tickLengthOut () const
 
int subTickCount () const
 
int subTickLengthIn () const
 
int subTickLengthOut () const
 
QPen basePen () const
 
QPen gridPen () const
 
QPen subGridPen () const
 
QPen zeroLinePen () const
 
QPen tickPen () const
 
QPen subTickPen () const
 
QFont labelFont () const
 
QColor labelColor () const
 
QString label () const
 
int labelPadding () const
 
int padding () const
 
SelectableParts selected () const
 
SelectableParts selectable () const
 
QFont selectedTickLabelFont () const
 
QFont selectedLabelFont () const
 
QColor selectedTickLabelColor () const
 
QColor selectedLabelColor () const
 
QPen selectedBasePen () const
 
QPen selectedTickPen () const
 
QPen selectedSubTickPen () const
 
void setScaleType (ScaleType type)
 
void setScaleLogBase (double base)
 
void setRange (double lower, double upper)
 
void setRange (double position, double size, Qt::AlignmentFlag alignment)
 
void setRangeLower (double lower)
 
void setRangeUpper (double upper)
 
void setRangeReversed (bool reversed)
 
void setAntialiasedGrid (bool enabled)
 
void setAntialiasedSubGrid (bool enabled)
 
void setAntialiasedZeroLine (bool enabled)
 
void setGrid (bool show)
 
void setSubGrid (bool show)
 
void setAutoTicks (bool on)
 
void setAutoTickCount (int approximateCount)
 
void setAutoTickLabels (bool on)
 
void setAutoTickStep (bool on)
 
void setAutoSubTicks (bool on)
 
void setTicks (bool show)
 
void setTickLabels (bool show)
 
void setTickLabelPadding (int padding)
 
void setTickLabelType (LabelType type)
 
void setTickLabelFont (const QFont &font)
 
void setTickLabelColor (const QColor &color)
 
void setTickLabelRotation (double degrees)
 
void setDateTimeFormat (const QString &format)
 
void setNumberFormat (const QString &formatCode)
 
void setNumberPrecision (int precision)
 
void setTickStep (double step)
 
void setTickVector (const QVector< double > &vec)
 
void setTickVectorLabels (const QVector< QString > &vec)
 
void setTickLength (int inside, int outside=0)
 
void setSubTickCount (int count)
 
void setSubTickLength (int inside, int outside=0)
 
void setBasePen (const QPen &pen)
 
void setGridPen (const QPen &pen)
 
void setSubGridPen (const QPen &pen)
 
void setZeroLinePen (const QPen &pen)
 
void setTickPen (const QPen &pen)
 
void setSubTickPen (const QPen &pen)
 
void setLabelFont (const QFont &font)
 
void setLabelColor (const QColor &color)
 
void setLabel (const QString &str)
 
void setLabelPadding (int padding)
 
void setPadding (int padding)
 
void setSelectedTickLabelFont (const QFont &font)
 
void setSelectedLabelFont (const QFont &font)
 
void setSelectedTickLabelColor (const QColor &color)
 
void setSelectedLabelColor (const QColor &color)
 
void setSelectedBasePen (const QPen &pen)
 
void setSelectedTickPen (const QPen &pen)
 
void setSelectedSubTickPen (const QPen &pen)
 
Qt::Orientation orientation () const
 
void moveRange (double diff)
 
void scaleRange (double factor, double center)
 
void setScaleRatio (const QCPAxis *otherAxis, double ratio=1.0)
 
double pixelToCoord (double value) const
 
double coordToPixel (double value) const
 
SelectablePart selectTest (const QPointF &pos) const
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *parentPlot)
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 
bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setAntialiased (bool enabled)
 

Protected Member Functions

void setAxisType (AxisType type)
 
void setAxisRect (const QRect &rect)
 
virtual void setupTickVectors ()
 
virtual void generateAutoTicks ()
 
virtual int calculateAutoSubTickCount (double tickStep) const
 
virtual int calculateMargin () const
 
virtual bool handleAxisSelection (QMouseEvent *event, bool additiveSelection, bool &modified)
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void drawTickLabel (QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
 
virtual void getMaxTickLabelSize (const QFont &font, const QString &text, QSize *tickLabelsSize) const
 
void visibleTickBounds (int &lowIndex, int &highIndex) const
 
double baseLog (double value) const
 
double basePow (double value) const
 
QPen getBasePen () const
 
QPen getTickPen () const
 
QPen getSubTickPen () const
 
QFont getTickLabelFont () const
 
QFont getLabelFont () const
 
QColor getTickLabelColor () const
 
QColor getLabelColor () const
 
- Protected Member Functions inherited from QCPLayerable
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
virtual QRect clipRect () const
 

Protected Attributes

QVector< double > mTickVector
 
QVector< QString > mTickVectorLabels
 
QCPRange mRange
 
QString mDateTimeFormat
 
QString mLabel
 
QRect mAxisRect
 
QPen mBasePen
 
QPen mTickPen
 
QPen mSubTickPen
 
QFont mTickLabelFont
 
QFont mLabelFont
 
QColor mTickLabelColor
 
QColor mLabelColor
 
LabelType mTickLabelType
 
ScaleType mScaleType
 
AxisType mAxisType
 
double mTickStep
 
double mScaleLogBase
 
double mScaleLogBaseLogInv
 
int mSubTickCount
 
int mTickLengthIn
 
int mTickLengthOut
 
int mSubTickLengthIn
 
int mSubTickLengthOut
 
int mAutoTickCount
 
int mTickLabelPadding
 
int mLabelPadding
 
int mPadding
 
double mTickLabelRotation
 
bool mTicks
 
bool mTickLabels
 
bool mAutoTicks
 
bool mAutoTickLabels
 
bool mAutoTickStep
 
bool mAutoSubTicks
 
bool mRangeReversed
 
SelectableParts mSelectable
 
SelectableParts mSelected
 
QFont mSelectedTickLabelFont
 
QFont mSelectedLabelFont
 
QColor mSelectedTickLabelColor
 
QColor mSelectedLabelColor
 
QPen mSelectedBasePen
 
QPen mSelectedTickPen
 
QPen mSelectedSubTickPen
 
QRect mAxisSelectionBox
 
QRect mTickLabelsSelectionBox
 
QRect mLabelSelectionBox
 
QCPGridmGrid
 
QVector< double > mSubTickVector
 
QChar mExponentialChar
 
QChar mPositiveSignChar
 
int mNumberPrecision
 
char mNumberFormatChar
 
bool mNumberBeautifulPowers
 
bool mNumberMultiplyCross
 
Qt::Orientation mOrientation
 
int mLowestVisibleTick
 
int mHighestVisibleTick
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QCPLayermLayer
 
bool mAntialiased
 

Friends

class QCustomPlot
 
class QCPGrid
 

Detailed Description

Manages a single axis inside a QCustomPlot.

Usually doesn't need to be instantiated externally. Access QCustomPlot's axes via QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and QCustomPlot::yAxis2 (right).

Member Enumeration Documentation

Defines at which side of the axis rect the axis will appear. This also affects how the tick marks are drawn, on which side the labels are placed etc.

See Also
setAxisType
Enumerator
atLeft 

Axis is vertical and on the left side of the axis rect of the parent QCustomPlot.

atRight 

Axis is vertical and on the right side of the axis rect of the parent QCustomPlot.

atTop 

Axis is horizontal and on the top side of the axis rect of the parent QCustomPlot.

atBottom 

Axis is horizontal and on the bottom side of the axis rect of the parent QCustomPlot.

When automatic tick label generation is enabled (setAutoTickLabels), defines how the numerical value (coordinate) of the tick position is translated into a string that will be drawn at the tick position.

See Also
setTickLabelType
Enumerator
ltNumber 

Tick coordinate is regarded as normal number and will be displayed as such. (see setNumberFormat)

ltDateTime 

Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC, see QDateTime::toTime_t) and will be displayed and formatted as such. (see setDateTimeFormat)

Defines the scale of an axis.

See Also
setScaleType
Enumerator
stLinear 

Normal linear scaling.

stLogarithmic 

Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power (see setScaleLogBase).

Defines the selectable parts of an axis.

See Also
setSelectable, setSelected
Enumerator
spNone 

None of the selectable parts.

spAxis 

The axis backbone and tick marks.

spTickLabels 

Tick labels (numbers) of this axis (as a whole, not individually)

spAxisLabel 

The axis label.

Constructor & Destructor Documentation

QCPAxis::QCPAxis ( QCustomPlot parentPlot,
AxisType  type 
)
explicit

Constructs an Axis instance of Type type inside parentPlot.

QCPAxis::~QCPAxis ( )
virtual

Member Function Documentation

bool QCPAxis::antialiasedGrid ( ) const
inline
bool QCPAxis::antialiasedSubGrid ( ) const
inline
bool QCPAxis::antialiasedZeroLine ( ) const
inline
void QCPAxis::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

Implements QCPLayerable.

bool QCPAxis::autoSubTicks ( ) const
inline
int QCPAxis::autoTickCount ( ) const
inline
bool QCPAxis::autoTickLabels ( ) const
inline
bool QCPAxis::autoTicks ( ) const
inline
bool QCPAxis::autoTickStep ( ) const
inline
QRect QCPAxis::axisRect ( ) const
inline
AxisType QCPAxis::axisType ( ) const
inline
double QCPAxis::baseLog ( double  value) const
protected
QPen QCPAxis::basePen ( ) const
inline
double QCPAxis::basePow ( double  value) const
protected
int QCPAxis::calculateAutoSubTickCount ( double  tickStep) const
protectedvirtual
int QCPAxis::calculateMargin ( ) const
protectedvirtual
double QCPAxis::coordToPixel ( double  value) const

Transforms value (in coordinates of the axis) to pixel coordinates of the QCustomPlot widget.

QString QCPAxis::dateTimeFormat ( ) const
inline
void QCPAxis::draw ( QCPPainter painter)
protectedvirtual

Implements QCPLayerable.

void QCPAxis::drawTickLabel ( QCPPainter painter,
double  position,
int  distanceToAxis,
const QString &  text,
QSize *  tickLabelsSize 
)
protectedvirtual
void QCPAxis::generateAutoTicks ( )
protectedvirtual
QPen QCPAxis::getBasePen ( ) const
protected
QColor QCPAxis::getLabelColor ( ) const
protected
QFont QCPAxis::getLabelFont ( ) const
protected
void QCPAxis::getMaxTickLabelSize ( const QFont &  font,
const QString &  text,
QSize *  tickLabelsSize 
) const
protectedvirtual
QPen QCPAxis::getSubTickPen ( ) const
protected
QColor QCPAxis::getTickLabelColor ( ) const
protected
QFont QCPAxis::getTickLabelFont ( ) const
protected
QPen QCPAxis::getTickPen ( ) const
protected
bool QCPAxis::grid ( ) const
inline
QPen QCPAxis::gridPen ( ) const
inline
bool QCPAxis::handleAxisSelection ( QMouseEvent *  event,
bool  additiveSelection,
bool &  modified 
)
protectedvirtual
QString QCPAxis::label ( ) const
inline
QColor QCPAxis::labelColor ( ) const
inline
QFont QCPAxis::labelFont ( ) const
inline
int QCPAxis::labelPadding ( ) const
inline
void QCPAxis::moveRange ( double  diff)

If the scale type (setScaleType) is stLinear, diff is added to the lower and upper bounds of the range. The range is simply moved by diff.

If the scale type is stLogarithmic, the range bounds are multiplied by diff. This corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff).

QString QCPAxis::numberFormat ( ) const
int QCPAxis::numberPrecision ( ) const
inline
Qt::Orientation QCPAxis::orientation ( ) const
inline

Returns the orientation of the axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom).

int QCPAxis::padding ( ) const
inline
double QCPAxis::pixelToCoord ( double  value) const

Transforms value (in pixel coordinates of the QCustomPlot widget) to axis coordinates.

const QCPRange QCPAxis::range ( ) const
inline
void QCPAxis::rangeChanged ( const QCPRange newRange)
signal

This signal is emitted when the range of this axis has changed. You can connect it to the setRange slot of another axis to communicate the new range to the other axis, in order for it to be synchronized.

bool QCPAxis::rangeReversed ( ) const
inline
double QCPAxis::scaleLogBase ( ) const
inline
void QCPAxis::scaleRange ( double  factor,
double  center 
)

Scales the range of this axis by factor around the coordinate center. For example, if factor is 2.0, center is 1.0, then the axis range will double its size, and the point at coordinate 1.0 won't have changed its position in the QCustomPlot widget (i.e. coordinates around 1.0 will have moved symmetrically closer to 1.0).

ScaleType QCPAxis::scaleType ( ) const
inline
SelectableParts QCPAxis::selectable ( ) const
inline
SelectableParts QCPAxis::selected ( ) const
inline
QPen QCPAxis::selectedBasePen ( ) const
inline
QColor QCPAxis::selectedLabelColor ( ) const
inline
QFont QCPAxis::selectedLabelFont ( ) const
inline
QPen QCPAxis::selectedSubTickPen ( ) const
inline
QColor QCPAxis::selectedTickLabelColor ( ) const
inline
QFont QCPAxis::selectedTickLabelFont ( ) const
inline
QPen QCPAxis::selectedTickPen ( ) const
inline
void QCPAxis::selectionChanged ( QCPAxis::SelectableParts  selection)
signal

This signal is emitted when the selection state of this axis has changed, either by user interaction or by a direct call to setSelected.

QCPAxis::SelectablePart QCPAxis::selectTest ( const QPointF &  pos) const

Returns the part of the axis that is hit by pos (in pixels). The return value of this function is independent of the user-selectable parts defined with setSelectable. Further, this function does not change the current selection state of the axis.

If the axis is not visible (setVisible), this function always returns spNone.

See Also
setSelected, setSelectable, QCustomPlot::setInteractions
void QCPAxis::setAntialiasedGrid ( bool  enabled)

Sets whether the grid of this axis is drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

void QCPAxis::setAntialiasedSubGrid ( bool  enabled)

Sets whether the sub grid of this axis is drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

void QCPAxis::setAntialiasedZeroLine ( bool  enabled)

Sets whether the zero line of this axis is drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

void QCPAxis::setAutoSubTicks ( bool  on)

Sets whether the number of sub ticks in one tick interval is determined automatically. This works, as long as the tick step mantissa is a multiple of 0.5 (which it is, when setAutoTickStep is enabled).
When on is set to false, you may set the sub tick count with setSubTickCount manually.

void QCPAxis::setAutoTickCount ( int  approximateCount)

When setAutoTickStep is true, approximateCount determines how many ticks should be generated in the visible range approximately.

void QCPAxis::setAutoTickLabels ( bool  on)

Sets whether the tick labels are generated automatically depending on the tick label type (ltNumber or ltDateTime).

If on is set to false, you should provide the tick labels via setTickVectorLabels. This is usually used in a combination with setAutoTicks set to false for complete control over tick positions and labels, e.g. when the ticks should be at multiples of pi and show "2pi", "3pi" etc. as tick labels.

If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

void QCPAxis::setAutoTicks ( bool  on)

Sets whether the tick positions should be calculated automatically (either from an automatically generated tick step or a tick step provided manually via setTickStep, see setAutoTickStep).

If on is set to false, you must provide the tick positions manually via setTickVector. For these manual ticks you may let QCPAxis generate the appropriate labels automatically by setting/leaving setAutoTickLabels true. If you also wish to control the displayed labels manually, set setAutoTickLabels to false and provide the label strings with setTickVectorLabels.

If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.

void QCPAxis::setAutoTickStep ( bool  on)

Sets whether the tick step, i.e. the interval between two (major) ticks, is calculated automatically. If on is set to true, the axis finds a tick step that is reasonable for human readable plots. This means the tick step mantissa is chosen such that it's either a multiple of two or ends in 0.5. The number of ticks the algorithm aims for within the visible range can be set with setAutoTickCount. It's not guaranteed that this number of ticks is met exactly, but approximately within a tolerance of two or three.

If on is set to false, you may set the tick step manually with setTickStep.

void QCPAxis::setAxisRect ( const QRect &  rect)
protected
void QCPAxis::setAxisType ( AxisType  type)
protected
void QCPAxis::setBasePen ( const QPen &  pen)

Sets the pen, the axis base line is drawn with.

See Also
setTickPen, setSubTickPen
void QCPAxis::setDateTimeFormat ( const QString &  format)

Sets the format in which dates and times are displayed as tick labels, if setTickLabelType is ltDateTime. for details about the format string, see the documentation of QDateTime::toString(). Newlines can be inserted with "\n".

void QCPAxis::setGrid ( bool  show)

Sets whether the grid lines are visible.

See Also
setSubGrid, setGridPen, setZeroLinePen
void QCPAxis::setGridPen ( const QPen &  pen)

Sets the pen, grid lines are drawn with.

See Also
setSubGridPen, setZeroLinePen
void QCPAxis::setLabel ( const QString &  str)

Sets the axis label that will be shown below/above or next to the axis, depending on its orientation.

void QCPAxis::setLabelColor ( const QColor &  color)

Sets the color of the axis label.

See Also
setLabelFont
void QCPAxis::setLabelFont ( const QFont &  font)

Sets the font of the axis label.

See Also
setLabelColor
void QCPAxis::setLabelPadding ( int  padding)

Sets the distance between the tick labels and the axis label.

See Also
setTickLabelPadding, setPadding
void QCPAxis::setNumberFormat ( const QString &  formatCode)

Sets the number format for the numbers drawn as tick labels (if tick label type is ltNumber). This formatCode is an extended version of the format code used e.g. by QString::number() and QLocale::toString(). For reference about that, see the "Argument Formats" section in the detailed description of the QString class. formatCode is a string of one, two or three characters. The first character is identical to the normal format code used by Qt. In short, this means: 'e'/'E' scientific format, 'f' fixed format, 'g'/'G' scientific or fixed, whichever is shorter.

The second and third characters are optional and specific to QCustomPlot:
If the first char was 'e' or 'g', numbers are/might be displayed in the scientific format, e.g. "5.5e9", which is ugly in a plot. So when the second char of formatCode is set to 'b' (for "beautiful"), those exponential numbers are formatted in a more natural way, i.e. "5.5 [multiplication sign] 10 [superscript] 9". By default, the multiplication sign is a centered dot. If instead a cross should be shown (as is usual in the USA), the third char of formatCode can be set to 'c'. The inserted multiplication signs are the UTF-8 characters 215 (0xD7) for the cross and 183 (0xB7) for the dot.

If the scale type (setScaleType) is stLogarithmic and the formatCode uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set the number precision to zero with setNumberPrecision.

Examples for formatCode:

  • g normal format code behaviour. If number is small, fixed format is used, if number is large, normal scientific format is used
  • gb If number is small, fixed format is used, if number is large, scientific format is used with beautifully typeset decimal powers and a dot as multiplication sign
  • ebc All numbers are in scientific format with beautifully typeset decimal power and a cross as multiplication sign
  • fb illegal format code, since fixed format doesn't support (or need) beautifully typeset decimal powers. Format code will be reduced to 'f'.
  • hello illegal format code, since first char is not 'e', 'E', 'f', 'g' or 'G'. Current format code will not be changed.
void QCPAxis::setNumberPrecision ( int  precision)

Sets the precision of the numbers drawn as tick labels. See QLocale::toString(double i, char f, int prec) for details. The effect of precisions are most notably for number Formats starting with 'e', see setNumberFormat

If the scale type (setScaleType) is stLogarithmic and the number format (setNumberFormat) uses the 'b' format code (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set precision to zero.

void QCPAxis::setPadding ( int  padding)

Sets the padding of the axis.

When QCustomPlot::setAutoMargin is enabled, the padding is the additional distance to the respective widget border, that is left blank. If padding is zero (default), the auto margin mechanism will find a margin that the axis label (or tick label, if no axis label is set) barely fits inside the QCustomPlot widget. To give the label closest to the border some freedom, increase padding.

The axis padding has no meaning if QCustomPlot::setAutoMargin is disabled.

See Also
setLabelPadding, setTickLabelPadding
void QCPAxis::setRange ( double  lower,
double  upper 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the lower and upper bound of the axis range.

To invert the direction of an axis range, use setRangeReversed.

There is also a slot to set a range, see setRange(const QCPRange &range).

void QCPAxis::setRange ( double  position,
double  size,
Qt::AlignmentFlag  alignment 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the range of the axis.

Parameters
positionthe position coordinate indicates together with the alignment parameter, where the new range will be positioned.
sizedefines the size (upper-lower) of the new axis range.
alignmentdetermines how position is to be interpreted.
If alignment is Qt::AlignLeft, position will be the lower bound of the range.
If alignment is Qt::AlignRight, position will be the upper bound of the range.
If alignment is Qt::AlignCenter, the new range will be centered around position.
Any other values for alignment will default to Qt::AlignCenter.
void QCPAxis::setRange ( const QCPRange range)
slot

Sets the range of the axis.

This slot may be connected with the rangeChanged signal of another axis so this axis is always synchronized with the other axis range, when it changes.

To invert the direction of an axis range, use setRangeReversed.

void QCPAxis::setRangeLower ( double  lower)

Sets the lower bound of the axis range, independently of the upper bound.

See Also
setRange
void QCPAxis::setRangeReversed ( bool  reversed)

Sets whether the axis range (direction) is displayed reversed. Normally, the values on horizontal axes increase left to right, on vertical axes bottom to top. When reversed is set to true, the direction of increasing values is inverted. Note that the range and data interface stays the same for reversed axes, e.g. the lower part of the setRange interface will still reference the mathematically smaller number than the upper part.

void QCPAxis::setRangeUpper ( double  upper)

Sets the upper bound of the axis range, independently of the lower bound.

See Also
setRange
void QCPAxis::setScaleLogBase ( double  base)

If setScaleType is set to stLogarithmic, base will be the logarithm base of the scaling. In logarithmic axis scaling, major tick marks appear at all powers of base.

Properties like tick step (setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing base 100, 1000 or even higher.

void QCPAxis::setScaleRatio ( const QCPAxis otherAxis,
double  ratio = 1.0 
)

Sets the range of this axis to have a certain scale ratio to otherAxis. For example, if ratio is 1, this axis is the yAxis and otherAxis is xAxis, graphs plotted with those axes will appear in a 1:1 ratio, independent of the aspect ratio the axis rect has. This is an operation that changes the range of this axis once, it doesn't fix the scale ratio indefinitely. Consequently calling this function in the constructor won't have the desired effect, since the widget's dimensions aren't defined yet, and a resizeEvent will follow.

void QCPAxis::setScaleType ( ScaleType  type)

Sets whether the axis uses a linear scale or a logarithmic scale. If type is set to stLogarithmic, the logarithm base can be set with setScaleLogBase. In logarithmic axis scaling, major tick marks appear at all powers of the logarithm base. Properties like tick step (setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing a logarithm base of 100, 1000 or even higher.

If type is stLogarithmic and the number format (setNumberFormat) uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set the number precision to zero with setNumberPrecision.

void QCPAxis::setSelectable ( const QCPAxis::SelectableParts &  selectable)
slot

Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectAxes.)

However, even when selectable is set to a value not allowing the selection of a specific part, it is still possible to set the selection of this part manually, by calling setSelected directly.

See Also
SelectablePart, setSelected
void QCPAxis::setSelected ( const QCPAxis::SelectableParts &  selected)
slot

Sets the selected state of the respective axis parts described by SelectablePart. When a part is selected, it uses a different pen/font.

The entire selection mechanism for axes is handled automatically when QCustomPlot::setInteractions contains iSelectAxes. You only need to call this function when you wish to change the selection state manually.

This function can change the selection state of a part even when setSelectable was set to a value that actually excludes the part.

emits the selectionChanged signal when selected is different from the previous selection state.

See Also
SelectablePart, setSelectable, selectTest, setSelectedBasePen, setSelectedTickPen, setSelectedSubTickPen, setSelectedTickLabelFont, setSelectedLabelFont, setSelectedTickLabelColor, setSelectedLabelColor
void QCPAxis::setSelectedBasePen ( const QPen &  pen)

Sets the pen that is used to draw the axis base line when selected.

See Also
setBasePen, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedLabelColor ( const QColor &  color)

Sets the color that is used for the axis label when it is selected.

See Also
setLabelColor, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedLabelFont ( const QFont &  font)

Sets the font that is used for the axis label when it is selected.

See Also
setLabelFont, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedSubTickPen ( const QPen &  pen)

Sets the pen that is used to draw the subticks when selected.

See Also
setSubTickPen, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedTickLabelColor ( const QColor &  color)

Sets the color that is used for tick labels when they are selected.

See Also
setTickLabelColor, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedTickLabelFont ( const QFont &  font)

Sets the font that is used for tick labels when they are selected.

See Also
setTickLabelFont, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSelectedTickPen ( const QPen &  pen)

Sets the pen that is used to draw the (major) ticks when selected.

See Also
setTickPen, setSelectable, setSelected, QCustomPlot::setInteractions
void QCPAxis::setSubGrid ( bool  show)

Sets whether the sub grid lines are visible.

See Also
setGrid, setSubGridPen, setZeroLinePen
void QCPAxis::setSubGridPen ( const QPen &  pen)

Sets the pen, the sub grid lines are drawn with. (By default, subgrid drawing needs to be enabled first with setSubGrid.)

See Also
setGridPen, setZeroLinePen
void QCPAxis::setSubTickCount ( int  count)

Sets the number of sub ticks in one (major) tick step. A sub tick count of three for example, divides the tick intervals in four sub intervals.

By default, the number of sub ticks is chosen automatically in a reasonable manner as long as the mantissa of the tick step is a multiple of 0.5 (which it is, when setAutoTickStep is enabled). If you want to disable automatic sub ticks and use this function to set the count manually, see setAutoSubTicks.

void QCPAxis::setSubTickLength ( int  inside,
int  outside = 0 
)

Sets the length of the subticks in pixels. inside is the length the subticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels will increase their distance to the axis accordingly, so they won't collide with the ticks.

See Also
setTickLength
void QCPAxis::setSubTickPen ( const QPen &  pen)

Sets the pen, subtick marks will be drawn with.

See Also
setSubTickCount, setSubTickLength, setBasePen
void QCPAxis::setTickLabelColor ( const QColor &  color)

Sets the color of the tick labels, i.e. the numbers drawn next to tick marks.

See Also
setTickLabelFont
void QCPAxis::setTickLabelFont ( const QFont &  font)

Sets the font of the tick labels, i.e. the numbers drawn next to tick marks.

See Also
setTickLabelColor
void QCPAxis::setTickLabelPadding ( int  padding)

Sets the distance between the axis base line (or any tick marks pointing outward) and the tick labels.

See Also
setLabelPadding, setPadding
void QCPAxis::setTickLabelRotation ( double  degrees)

Sets the rotation of the tick labels, i.e. the numbers drawn next to tick marks. If degrees is zero, the labels are drawn normally. Else, the tick labels are drawn rotated by degrees clockwise. The specified angle is bound to values from -90 to 90 degrees.

void QCPAxis::setTickLabels ( bool  show)

Sets whether tick labels are displayed.

void QCPAxis::setTickLabelType ( LabelType  type)

Sets whether the tick labels display numbers or dates/times.
If type is set to ltNumber, the format specifications of setNumberFormat apply.
If type is set to ltDateTime, the format specifications of setDateTimeFormat apply.
In QCustomPlot, date/time coordinates are double numbers representing the seconds since 1970-01-01T00:00:00 UTC. This format can be retrieved from QDateTime objects with the QDateTime::toTime_t() function. Since this only gives a resolution of one second, there is also the QDateTime::toMSecsSinceEpoch() function which returns the timespan described above in milliseconds. Divide its return value by 1000.0 to get a value with the format needed for date/time plotting, this time with a resolution of one millisecond.

void QCPAxis::setTickLength ( int  inside,
int  outside = 0 
)

Sets the length of the ticks in pixels. inside is the length the ticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels will increase their distance to the axis accordingly, so they won't collide with the ticks.

See Also
setSubTickLength
void QCPAxis::setTickPen ( const QPen &  pen)

Sets the pen, tick marks will be drawn with.

See Also
setTickLength, setBasePen
void QCPAxis::setTicks ( bool  show)

Sets whether tick marks are displayed. Setting show to false does not imply, that tick labels are invisible, too. To achieve that, see setTickLabels.

void QCPAxis::setTickStep ( double  step)

If setAutoTickStep is set to false, use this function to set the tick step manually. The tick step is the interval between (major) ticks, in plot coordinates.

See Also
setSubTickCount
void QCPAxis::setTickVector ( const QVector< double > &  vec)

If you want full control over what ticks (and possibly labels) the axes show, this function is used to set the coordinates at which ticks will appear.setAutoTicks must be disabled, else the provided tick vector will be overwritten with automatically generated tick coordinates. The labels of the ticks can either be generated automatically when setAutoTickLabels is left enabled, or be set manually with setTickVectorLabels, when setAutoTickLabels is disabled.

vec is a vector containing the positions of the ticks.

See Also
setTickVectorLabels
void QCPAxis::setTickVectorLabels ( const QVector< QString > &  vec)

If you want full control over what ticks and labels the axes show, this function is used to set a number of QStrings that will be displayed at the tick positions which you need to provide with setTickVector. These two vectors should have the same size. (Note that you need to disable setAutoTicks and setAutoTickLabels first.)

vec is a vector containing the labels of the ticks.

See Also
setTickVector
void QCPAxis::setupTickVectors ( )
protectedvirtual
void QCPAxis::setZeroLinePen ( const QPen &  pen)

Sets the pen with which a single grid-like line will be drawn at value position zero. The line will be drawn instead of a grid line at that position, and not on top. To disable the drawing of a zero-line, set pen to Qt::NoPen. Then, if setGrid is enabled, a grid line will be drawn instead.

See Also
setGrid, setGridPen
bool QCPAxis::subGrid ( ) const
inline
QPen QCPAxis::subGridPen ( ) const
inline
int QCPAxis::subTickCount ( ) const
inline
int QCPAxis::subTickLengthIn ( ) const
inline
int QCPAxis::subTickLengthOut ( ) const
inline
QPen QCPAxis::subTickPen ( ) const
inline
QColor QCPAxis::tickLabelColor ( ) const
inline
QFont QCPAxis::tickLabelFont ( ) const
inline
int QCPAxis::tickLabelPadding ( ) const
inline
double QCPAxis::tickLabelRotation ( ) const
inline
bool QCPAxis::tickLabels ( ) const
inline
LabelType QCPAxis::tickLabelType ( ) const
inline
int QCPAxis::tickLengthIn ( ) const
inline
int QCPAxis::tickLengthOut ( ) const
inline
QPen QCPAxis::tickPen ( ) const
inline
bool QCPAxis::ticks ( ) const
inline
void QCPAxis::ticksRequest ( )
signal

This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels and replot itself.

Modifying the tick positions can be done with setTickVector. If you also want to control the tick labels, set setAutoTickLabels to false and also provide the labels with setTickVectorLabels.

If you only want static ticks you probably don't need this signal, since you can just set the tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this signal and set the vector/vectors there.

double QCPAxis::tickStep ( ) const
inline
QVector<double> QCPAxis::tickVector ( ) const
inline
QVector<QString> QCPAxis::tickVectorLabels ( ) const
inline
void QCPAxis::visibleTickBounds ( int &  lowIndex,
int &  highIndex 
) const
protected
QPen QCPAxis::zeroLinePen ( ) const
inline

Friends And Related Function Documentation

friend class QCPGrid
friend
friend class QCustomPlot
friend

Member Data Documentation

bool QCPAxis::mAutoSubTicks
protected
int QCPAxis::mAutoTickCount
protected
bool QCPAxis::mAutoTickLabels
protected
bool QCPAxis::mAutoTicks
protected
bool QCPAxis::mAutoTickStep
protected
QRect QCPAxis::mAxisRect
protected
QRect QCPAxis::mAxisSelectionBox
protected
AxisType QCPAxis::mAxisType
protected
QPen QCPAxis::mBasePen
protected
QString QCPAxis::mDateTimeFormat
protected
QChar QCPAxis::mExponentialChar
protected
QCPGrid* QCPAxis::mGrid
protected
int QCPAxis::mHighestVisibleTick
protected
QString QCPAxis::mLabel
protected
QColor QCPAxis::mLabelColor
protected
QFont QCPAxis::mLabelFont
protected
int QCPAxis::mLabelPadding
protected
QRect QCPAxis::mLabelSelectionBox
protected
int QCPAxis::mLowestVisibleTick
protected
bool QCPAxis::mNumberBeautifulPowers
protected
char QCPAxis::mNumberFormatChar
protected
bool QCPAxis::mNumberMultiplyCross
protected
int QCPAxis::mNumberPrecision
protected
Qt::Orientation QCPAxis::mOrientation
protected
int QCPAxis::mPadding
protected
QChar QCPAxis::mPositiveSignChar
protected
QCPRange QCPAxis::mRange
protected
bool QCPAxis::mRangeReversed
protected
double QCPAxis::mScaleLogBase
protected
double QCPAxis::mScaleLogBaseLogInv
protected
ScaleType QCPAxis::mScaleType
protected
SelectableParts QCPAxis::mSelectable
protected
SelectableParts QCPAxis::mSelected
protected
QPen QCPAxis::mSelectedBasePen
protected
QColor QCPAxis::mSelectedLabelColor
protected
QFont QCPAxis::mSelectedLabelFont
protected
QPen QCPAxis::mSelectedSubTickPen
protected
QColor QCPAxis::mSelectedTickLabelColor
protected
QFont QCPAxis::mSelectedTickLabelFont
protected
QPen QCPAxis::mSelectedTickPen
protected
int QCPAxis::mSubTickCount
protected
int QCPAxis::mSubTickLengthIn
protected
int QCPAxis::mSubTickLengthOut
protected
QPen QCPAxis::mSubTickPen
protected
QVector<double> QCPAxis::mSubTickVector
protected
QColor QCPAxis::mTickLabelColor
protected
QFont QCPAxis::mTickLabelFont
protected
int QCPAxis::mTickLabelPadding
protected
double QCPAxis::mTickLabelRotation
protected
bool QCPAxis::mTickLabels
protected
QRect QCPAxis::mTickLabelsSelectionBox
protected
LabelType QCPAxis::mTickLabelType
protected
int QCPAxis::mTickLengthIn
protected
int QCPAxis::mTickLengthOut
protected
QPen QCPAxis::mTickPen
protected
bool QCPAxis::mTicks
protected
double QCPAxis::mTickStep
protected
QVector<double> QCPAxis::mTickVector
protected
QVector<QString> QCPAxis::mTickVectorLabels
protected

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