altair.AxisConfig

class altair.AxisConfig(bandPosition=Undefined, disable=Undefined, domain=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, grid=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, style=Undefined, tickBand=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=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, **kwds)

AxisConfig schema wrapper

Mapping(required=[])

Attributes
bandPositionfloat

An interpolation fraction indicating where, for band scales, axis ticks should be positioned. A value of 0 places ticks at the left edge of their bands. A value of 0.5 places ticks in the middle of their bands.

Default value: 0.5

disableboolean

Disable axis by default.

domainboolean

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

Default value: true

domainColoranyOf(None, Color)

Color of axis domain line.

Default value: "gray".

domainDashList(float)

An array of alternating [stroke, space] lengths for dashed domain lines.

domainDashOffsetfloat

The pixel offset at which to start drawing with the domain dash array.

domainOpacityfloat

Opacity of the axis domain line.

domainWidthfloat

Stroke width of axis domain line

Default value: 1

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.

gridColoranyOf(anyOf(None, Color), ConditionalAxisColor)
gridDashanyOf(List(float), ConditionalAxisNumberArray)
gridDashOffsetanyOf(float, ConditionalAxisNumber)
gridOpacityanyOf(float, ConditionalAxisNumber)
gridWidthanyOf(float, ConditionalAxisNumber)
labelAlignanyOf(Align, ConditionalAxisLabelAlign)
labelAnglefloat

The rotation angle of the axis labels.

Default value: -90 for nominal and ordinal fields; 0 otherwise.

labelBaselineanyOf(TextBaseline, ConditionalAxisLabelBaseline)
labelBoundanyOf(float, boolean)

Indicates if labels should be hidden if they exceed the axis range. If false (the default) no bounds overlap analysis is performed. If true, labels will be hidden if they exceed the axis range by more than 1 pixel. If this property is a number, it specifies the pixel tolerance: the maximum amount by which a label bounding box may exceed the axis range.

Default value: false.

labelColoranyOf(anyOf(None, Color), 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.

labelFlushOffsetfloat

Indicates the number of pixels by which to offset flush-adjusted labels. For example, a value of 2 will push flush-adjusted labels 2 pixels outward from the center of the axis. Offsets can help the labels better visually group with corresponding axis ticks.

Default value: 0.

labelFontanyOf(string, ConditionalAxisString)
labelFontSizeanyOf(float, ConditionalAxisNumber)
labelFontStyleanyOf(FontStyle, ConditionalAxisLabelFontStyle)
labelFontWeightanyOf(FontWeight, ConditionalAxisLabelFontWeight)
labelLimitfloat

Maximum allowed pixel width of axis tick labels.

Default value: 180

labelLineHeightfloat

Line height in pixels for multi-line label text.

labelOffsetanyOf(float, ConditionalAxisNumber)
labelOpacityanyOf(float, ConditionalAxisNumber)
labelOverlapLabelOverlap

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, ConditionalAxisNumber)
labelSeparationfloat

The minimum separation that must be between label bounding boxes for them to be considered non-overlapping (default 0 ). This property is ignored if labelOverlap resolution is not enabled.

labelsboolean

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

Default value: true.

maxExtentfloat

The maximum extent in pixels that axis ticks and labels should use. This determines a maximum offset value for axis titles.

Default value: undefined.

minExtentfloat

The minimum extent in pixels that axis ticks and labels should use. This determines a minimum offset value for axis titles.

Default value: 30 for y-axis; undefined for x-axis.

offsetfloat

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)

orientAxisOrient

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.

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).

tickBandenum(‘center’, ‘extent’)

For band scales, indicates if ticks and grid lines should be placed at the center of a band (default) or at the band extents to indicate intervals.

tickColoranyOf(anyOf(None, Color), ConditionalAxisColor)
tickCountfloat

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.

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

tickDashanyOf(List(float), ConditionalAxisNumberArray)
tickDashOffsetanyOf(float, 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.

tickOffsetfloat

Position offset in pixels to apply to ticks, labels, and gridlines.

tickOpacityanyOf(float, ConditionalAxisNumber)
tickRoundboolean

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

Default value: true

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

Boolean value that determines whether the axis should include ticks.

Default value: true

titleNone

Set to null to disable title for the axis, legend, or header.

titleAlignAlign

Horizontal text alignment of axis titles.

titleAnchorTitleAnchor

Text anchor position for placing axis titles.

titleAnglefloat

Angle in degrees of axis titles.

titleBaselineTextBaseline

Vertical text baseline for axis titles.

titleColoranyOf(None, Color)

Color of the title, can be in hex color code or regular color name.

titleFontstring

Font of the title. (e.g., "Helvetica Neue" ).

titleFontSizefloat

Font size of the title.

titleFontStyleFontStyle

Font style of the title.

titleFontWeightFontWeight

Font weight of the title. This can be either a string (e.g "bold", "normal" ) or a number ( 100, 200, 300, …, 900 where "normal" = 400 and "bold" = 700 ).

titleLimitfloat

Maximum allowed pixel width of axis titles.

titleLineHeightfloat

Line height in pixels for multi-line title text.

titleOpacityfloat

Opacity of the axis title.

titlePaddingfloat

The padding, in pixels, between title and axis.

titleXfloat

X-coordinate of the axis title relative to the axis group.

titleYfloat

Y-coordinate of the axis title relative to the axis group.

translatefloat

Translation offset in pixels applied to the axis group mark x and y. If specified, overrides the default behavior of a 0.5 offset to pixel-align stroked lines.

__init__(self, bandPosition=Undefined, disable=Undefined, domain=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, grid=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, style=Undefined, tickBand=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=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, **kwds)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self[, bandPosition, disable, …])

Initialize self.

copy(self[, 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(self[, validate, ignore, context])

Return a dictionary representation of the object

to_json(self[, validate, ignore, context, …])

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

copy(self, deep=True, ignore=())

Return a copy of the object

Parameters
deepboolean or list, optional

If True (default) then return a deep copy of all dict, list, and SchemaBase objects within the object structure. If False, then only copy the top object. If a list or iterable, then only copy the listed attributes.

ignorelist, optional

A list of keys for which the contents should not be copied, but only stored by reference.

classmethod from_dict(dct, validate=True, _wrapper_classes=None)

Construct class from a dictionary representation

Parameters
dctdictionary

The dict from which to construct the class

validateboolean

If True (default), then validate the input against the schema.

_wrapper_classeslist (optional)

The set of SchemaBase classes to use when constructing wrappers of the dict inputs. If not specified, the result of cls._default_wrapper_classes will be used.

Returns
objSchema object

The wrapped schema

Raises
jsonschema.ValidationError :

if validate=True and dct does not conform to the schema

classmethod from_json(json_string, validate=True, **kwargs)

Instantiate the object from a valid JSON string

Parameters
json_stringstring

The string containing a valid JSON chart specification.

validateboolean

If True (default), then validate the input against the schema.

**kwargs :

Additional keyword arguments are passed to json.loads

Returns
chartChart object

The altair Chart object built from the specification.

classmethod resolve_references(schema=None)

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

to_dict(self, validate=True, ignore=None, context=None)

Return a dictionary representation of the object

Parameters
validateboolean or string

If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.

ignorelist

A list of keys to ignore. This will not passed to child to_dict function calls.

contextdict (optional)

A context dictionary that will be passed to all child to_dict function calls

Returns
dctdictionary

The dictionary representation of this object

Raises
jsonschema.ValidationError :

if validate=True and the dict does not conform to the schema

to_json(self, validate=True, ignore=[], context={}, indent=2, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters
validateboolean or string

If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.

ignorelist

A list of keys to ignore. This will not passed to child to_dict function calls.

contextdict (optional)

A context dictionary that will be passed to all child to_dict function calls

indentinteger, default 2

the number of spaces of indentation to use

sort_keysboolean, default True

if True, sort keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns
specstring

The JSON specification of the chart object.

classmethod validate(instance, schema=None)

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

classmethod validate_property(name, value, schema=None)

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