This website is for version 5. You can find the documentation for version 4 here.

Point#

point mark represents each data point with a symbol. Point marks are commonly used in visualizations like scatter plots.

Point Mark Properties#

Click to show code
import altair as alt
from vega_datasets import data

source = data.cars()

shape_select = alt.binding_select(
    options=[
        "arrow",
        "circle",
        "square",
        "cross",
        "diamond",
        "triangle",
        "triangle-up",
        "triangle-down",
        "triangle-right",
        "triangle-left",
        "wedge",
        "stroke",
        "M-1,-1H1V1H-1Z",
        "M0,.5L.6,.8L.5,.1L1,-.3L.3,-.4L0,-1L-.3,-.4L-1,-.3L-.5,.1L-.6,.8L0,.5Z",
    ],
    name="shape",
)
shape_var = alt.param(bind=shape_select, value="circle")

angle_slider = alt.binding_range(min=-360, max=360, step=1, name="angle")
angle_var = alt.param(bind=angle_slider, value=0)

size_slider = alt.binding_range(min=0, max=500, step=10, name="size")
size_var = alt.param(bind=size_slider, value=50)

strokeWidth_slider = alt.binding_range(min=0, max=10, step=0.5, name="strokeWidth")
strokeWidth_var = alt.param(bind=strokeWidth_slider, value=2)

alt.Chart(source).mark_point(
    shape=shape_var,
    angle=angle_var,
    size=size_var,
    strokeWidth=strokeWidth_var,
).encode(x="Horsepower:Q", y="Miles_per_Gallon:Q").add_params(
    shape_var, angle_var, size_var, strokeWidth_var
)

A point mark definition can contain any standard mark properties and the following special properties:

Click to show table

Property

Type

Description

shape

anyOf(anyOf(SymbolShape, string), ExprRef)

Shape of the point marks. Supported values include:

  • plotting shapes: "circle", "square", "cross", "diamond", "triangle-up", "triangle-down", "triangle-right", or "triangle-left".

  • the line symbol "stroke"

  • centered directional shapes "arrow", "wedge", or "triangle"

  • a custom SVG path string (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)

Default value: "circle"

size

anyOf(number, ExprRef)

Default size for marks.

  • For point/circle/square, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.

  • For bar, this represents the band size of the bar, in pixels.

  • For text, this represents the font size, in pixels.

Default value:

  • 30 for point, circle, square marks; width/height’s step

  • 2 for bar marks with discrete dimensions;

  • 5 for bar marks with continuous dimensions;

  • 11 for text marks.

Examples#

Dot Plot#

Mapping a field to either only x or only y of point marks creates a dot plot.

import altair as alt
from vega_datasets import data

source = data.movies()
alt.Chart(source).mark_point().encode(
    x="IMDB_Rating:Q"
)