AxisItem

class pyqtgraph.AxisItem(orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)

GraphicsItem showing a single plot axis with ticks, values, and label. Can be configured to fit on any side of a plot, and can automatically synchronize its displayed scale with ViewBox items. Ticks can be extended to draw a grid. If maxTickLength is negative, ticks point into the plot.

__init__(orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)
Arguments:  
orientation one of ‘left’, ‘right’, ‘top’, or ‘bottom’
maxTickLength (px) maximum length of ticks to draw. Negative values draw into the plot, positive values draw outward.
linkView (ViewBox) causes the range of values displayed in the axis to be linked to the visible range of a ViewBox.
showValues (bool) Whether to display values adjacent to ticks
pen (QPen) Pen used when drawing ticks.
linkToView(view)

Link this axis to a ViewBox, causing its displayed range to match the visible range of the view.

linkedView()

Return the ViewBox this axis is linked to

setGrid(grid)

Set the alpha value for the grid, or False to disable.

setHeight(h=None)

Set the height of this axis reserved for ticks and tick labels. The height of the axis label is automatically added.

setLabel(text=None, units=None, unitPrefix=None, **args)

Set the text displayed adjacent to the axis.

setLogMode(log)

If log is True, then ticks are displayed on a logarithmic scale and values are adjusted accordingly. (This is usually accessed by changing the log mode of a PlotItem)

setPen(pen)

Set the pen used for drawing text, axes, ticks, and grid lines. if pen == None, the default will be used (see setConfigOption)

setRange(mn, mx)

Set the range of values displayed by the axis. Usually this is handled automatically by linking the axis to a ViewBox with linkToView

setScale(scale=None)

Set the value scaling for this axis. Values on the axis are multiplied by this scale factor before being displayed as text. By default, this scaling value is automatically determined based on the visible range and the axis units are updated to reflect the chosen scale factor.

For example: If the axis spans values from -0.1 to 0.1 and has units set to ‘V’ then a scale of 1000 would cause the axis to display values -100 to 100 and the units would appear as ‘mV’

setTicks(ticks)

Explicitly determine which ticks to display. This overrides the behavior specified by tickSpacing(), tickValues(), and tickStrings() The format for ticks looks like:

[
    [ (majorTickValue1, majorTickString1), (majorTickValue2, majorTickString2), ... ],
    [ (minorTickValue1, minorTickString1), (minorTickValue2, minorTickString2), ... ],
    ...
]

If ticks is None, then the default tick system will be used instead.

setWidth(w=None)

Set the width of this axis reserved for ticks and tick labels. The width of the axis label is automatically added.

showLabel(show=True)

Show/hide the label text for this axis.

tickSpacing(minVal, maxVal, size)

Return values describing the desired spacing and offset of ticks.

This method is called whenever the axis needs to be redrawn and is a good method to override in subclasses that require control over tick locations.

The return value must be a list of three tuples:

[
    (major tick spacing, offset),
    (minor tick spacing, offset),
    (sub-minor tick spacing, offset),
    ...
]
tickStrings(values, scale, spacing)

Return the strings that should be placed next to ticks. This method is called when redrawing the axis and is a good method to override in subclasses. The method is called with a list of tick values, a scaling factor (see below), and the spacing between ticks (this is required since, in some instances, there may be only one tick and thus no other way to determine the tick spacing)

The scale argument is used when the axis label is displaying units which may have an SI scaling prefix. When determining the text to display, use value*scale to correctly account for this prefix. For example, if the axis label’s units are set to ‘V’, then a tick value of 0.001 might be accompanied by a scale value of 1000. This indicates that the label is displaying ‘mV’, and thus the tick should display 0.001 * 1000 = 1.

tickValues(minVal, maxVal, size)

Return the values and spacing of ticks to draw:

[  
    (spacing, [major ticks]), 
    (spacing, [minor ticks]), 
    ... 
]

By default, this method calls tickSpacing to determine the correct tick locations. This is a good method to override in subclasses.

Previous topic

IsocurveItem

Next topic

TextItem

This Page