altair.Axis#

class altair.Axis(aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds)#

Axis schema wrapper

Mapping(required=[])

Attributes
ariaanyOf(boolean, ExprRef)
bandPositionanyOf(float, ExprRef)
descriptionanyOf(string, ExprRef)
domainboolean

A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.

Default value: true

domainCapanyOf(StrokeCap, ExprRef)
domainColoranyOf(anyOf(None, Color), ExprRef)
domainDashanyOf(List(float), ExprRef)
domainDashOffsetanyOf(float, ExprRef)
domainOpacityanyOf(float, ExprRef)
domainWidthanyOf(float, ExprRef)
formatanyOf(string, Dict)

When used with the default "number" and "time" format type, the text formatting pattern for labels of guides (axes, legends, headers) and text marks.

See the format documentation for more examples.

When used with a custom formatType, this value will be passed as format alongside datum.value to the registered function.

Default value: Derived from numberFormat config for number format and from timeFormat config for time format.

formatTypestring

The format type for labels. One of "number", "time", or a registered custom format type.

Default value:

  • "time" for temporal fields and ordinal and nominal fields with timeUnit.

  • "number" for quantitative fields as well as ordinal and nominal fields without timeUnit.

gridboolean

A boolean flag indicating if grid lines should be included as part of the axis

Default value: true for continuous scales that are not binned; otherwise, false.

gridCapanyOf(StrokeCap, ExprRef)
gridColoranyOf(anyOf(None, Color), ExprRef,
:class:`ConditionalAxisColor`)
gridDashanyOf(List(float), ExprRef, ConditionalAxisNumberArray)
gridDashOffsetanyOf(float, ExprRef, ConditionalAxisNumber)
gridOpacityanyOf(float, ExprRef, ConditionalAxisNumber)
gridWidthanyOf(float, ExprRef, ConditionalAxisNumber)
labelAlignanyOf(Align, ExprRef, ConditionalAxisLabelAlign)
labelAngleanyOf(float, ExprRef)
labelBaselineanyOf(TextBaseline, ExprRef,
:class:`ConditionalAxisLabelBaseline`)
labelBoundanyOf(anyOf(float, boolean), ExprRef)
labelColoranyOf(anyOf(None, Color), ExprRef,
:class:`ConditionalAxisColor`)
labelExprstring

Vega expression for customizing labels.

Note: The label text and value can be assessed via the label and value properties of the axis’s backing datum object.

labelFlushanyOf(boolean, float)

Indicates if the first and last axis labels should be aligned flush with the scale range. Flush alignment for a horizontal axis will left-align the first label and right-align the last label. For vertical axes, bottom and top text baselines are applied instead. If this property is a number, it also indicates the number of pixels by which to offset the first and last labels; for example, a value of 2 will flush-align the first and last labels and also push them 2 pixels outward from the center of the axis. The additional adjustment can sometimes help the labels better visually group with corresponding axis ticks.

Default value: true for axis of a continuous x-scale. Otherwise, false.

labelFlushOffsetanyOf(float, ExprRef)
labelFontanyOf(string, ExprRef, ConditionalAxisString)
labelFontSizeanyOf(float, ExprRef, ConditionalAxisNumber)
labelFontStyleanyOf(FontStyle, ExprRef,
:class:`ConditionalAxisLabelFontStyle`)
labelFontWeightanyOf(FontWeight, ExprRef,
:class:`ConditionalAxisLabelFontWeight`)
labelLimitanyOf(float, ExprRef)
labelLineHeightanyOf(float, ExprRef)
labelOffsetanyOf(float, ExprRef, ConditionalAxisNumber)
labelOpacityanyOf(float, ExprRef, ConditionalAxisNumber)
labelOverlapanyOf(LabelOverlap, ExprRef)

The strategy to use for resolving overlap of axis labels. If false (the default), no overlap reduction is attempted. If set to true or "parity", a strategy of removing every other label is used (this works well for standard linear axes). If set to "greedy", a linear scan of the labels is performed, removing any labels that overlaps with the last visible label (this often works better for log-scaled axes).

Default value: true for non-nominal fields with non-log scales; "greedy" for log scales; otherwise false.

labelPaddinganyOf(float, ExprRef, ConditionalAxisNumber)
labelSeparationanyOf(float, ExprRef)
labelsboolean

A boolean flag indicating if labels should be included as part of the axis.

Default value: true.

maxExtentanyOf(float, ExprRef)
minExtentanyOf(float, ExprRef)
offsetanyOf(float, ExprRef)

The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.

Default value: derived from the axis config ‘s offset ( 0 by default)

orientanyOf(AxisOrient, ExprRef)

The orientation of the axis. One of "top", "bottom", "left" or "right". The orientation can be used to further specialize the axis type (e.g., a y-axis oriented towards the right edge of the chart).

Default value: "bottom" for x-axes and "left" for y-axes.

positionanyOf(float, ExprRef)

The anchor position of the axis in pixels. For x-axes with top or bottom orientation, this sets the axis group x coordinate. For y-axes with left or right orientation, this sets the axis group y coordinate.

Default value : 0

styleanyOf(string, List(string))

A string or array of strings indicating the name of custom styles to apply to the axis. A style is a named collection of axis property defined within the style configuration. If style is an array, later styles will override earlier styles.

Default value: (none) Note: Any specified style will augment the default style. For example, an x-axis mark with "style": "foo" will use config.axisX and config.style.foo (the specified style "foo" has higher precedence).

tickBandanyOf(enum(‘center’, ‘extent’), ExprRef)
tickCapanyOf(StrokeCap, ExprRef)
tickColoranyOf(anyOf(None, Color), ExprRef,
:class:`ConditionalAxisColor`)
tickCountanyOf(float, TimeInterval, TimeIntervalStep, ExprRef)

A desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are “nice” (multiples of 2, 5, 10) and lie within the underlying scale’s range.

For scales of type "time" or "utc", the tick count can instead be a time interval specifier. Legal string values are "millisecond", "second", "minute", "hour", "day", "week", "month", and "year". Alternatively, an object-valued interval specifier of the form {"interval": "month", "step": 3} includes a desired number of interval steps. Here, ticks are generated for each quarter (Jan, Apr, Jul, Oct) boundary.

Default value : Determine using a formula ceil(width/40) for x and ceil(height/40) for y.

tickDashanyOf(List(float), ExprRef, ConditionalAxisNumberArray)
tickDashOffsetanyOf(float, ExprRef, ConditionalAxisNumber)
tickExtraboolean

Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for band scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with "bandPosition": 1 and an axis "padding" value of 0.

tickMinStepanyOf(float, ExprRef)

The minimum desired step between axis ticks, in terms of scale domain values. For example, a value of 1 indicates that ticks should not be less than 1 unit apart. If tickMinStep is specified, the tickCount value will be adjusted, if necessary, to enforce the minimum step value.

tickOffsetanyOf(float, ExprRef)
tickOpacityanyOf(float, ExprRef, ConditionalAxisNumber)
tickRoundboolean

Boolean flag indicating if pixel position values should be rounded to the nearest integer.

Default value: true

tickSizeanyOf(float, ExprRef, ConditionalAxisNumber)
tickWidthanyOf(float, ExprRef, ConditionalAxisNumber)
ticksboolean

Boolean value that determines whether the axis should include ticks.

Default value: true

titleanyOf(Text, None)

A title for the field. If null, the title will be removed.

Default value: derived from the field’s name and transformation function ( aggregate, bin and timeUnit ). If the field has an aggregate function, the function is displayed as part of the title (e.g., "Sum of Profit" ). If the field is binned or has a time unit applied, the applied function is shown in parentheses (e.g., "Profit (binned)", "Transaction Date (year-month)" ). Otherwise, the title is simply the field name.

Notes :

1) You can customize the default field title format by providing the fieldTitle property in the config or fieldTitle function via the compile function’s options.

2) If both field definition’s title and axis, header, or legend title are defined, axis/header/legend title will be used.

titleAlignanyOf(Align, ExprRef)
titleAnchoranyOf(TitleAnchor, ExprRef)
titleAngleanyOf(float, ExprRef)
titleBaselineanyOf(TextBaseline, ExprRef)
titleColoranyOf(anyOf(None, Color), ExprRef)
titleFontanyOf(string, ExprRef)
titleFontSizeanyOf(float, ExprRef)
titleFontStyleanyOf(FontStyle, ExprRef)
titleFontWeightanyOf(FontWeight, ExprRef)
titleLimitanyOf(float, ExprRef)
titleLineHeightanyOf(float, ExprRef)
titleOpacityanyOf(float, ExprRef)
titlePaddinganyOf(float, ExprRef)
titleXanyOf(float, ExprRef)
titleYanyOf(float, ExprRef)
translateanyOf(float, ExprRef)
valuesanyOf(List(float), List(string), List(boolean), List(DateTime),
:class:`ExprRef`)

Explicitly set the visible axis tick values.

zindexfloat

A non-negative integer indicating the z-index of the axis. If zindex is 0, axes should be drawn behind all chart elements. To put them in front, set zindex to 1 or more.

Default value: 0 (behind the marks).

__init__(aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds)#

Methods

__init__([aria, bandPosition, description, ...])

copy([deep, ignore])

Return a copy of the object

from_dict(dct[, validate, _wrapper_classes])

Construct class from a dictionary representation

from_json(json_string[, validate])

Instantiate the object from a valid JSON string

resolve_references([schema])

Resolve references in the context of this object's schema or root schema.

to_dict([validate, ignore, context])

Return a dictionary representation of the object

to_json([validate, ignore, context, indent, ...])

Emit the JSON representation for this object as a string.

validate(instance[, schema])

Validate the instance against the class schema in the context of the rootschema.

validate_property(name, value[, schema])

Validate a property against property schema in the context of the rootschema