Scatterplot#

import altair_express as alx
from vega_datasets import data
df = data.cars()

alx.highlight_brush() + alx.scatterplot(df,x='Horsepower',y='Miles_per_Gallon')

The scatterplot() function is useful for exploring the relationship between two continuous variables. This visualization allows you to see the distribution of the data points and the relationship between the variables, making it easy to identify patterns and correlations in the data.

Parameters#

datapandas dataframe

The data to visualize as a pandas dataframe.

xstring

The column name of the data to be on the x-axis.

ystring

The column name of the data to be on the y-axis

x_axisalt.Axis() Object or None

The column name of the data to be on the x-axis.

y_axisalt.Axis() Object or None

The column name of the data to be on the y-axis

colorstring

A valid CSS color to make the chart or a column name in the dataframe to color the bars by.

widthint

The width of the chart in pixels.

heightint

The height of the chart in pixels.

effectsEffect Objects

The effects of interactions to be applied to the chart.

Examples#

Interactive Brush#

import altair_express as alx
from vega_datasets import data
df = data.cars()

alx.highlight_brush() + alx.scatterplot(df,x='Horsepower',y='Miles_per_Gallon')

Split by color#

import altair_express as alx
from vega_datasets import data
df = data.cars()

alx.highlight_color() + alx.scatterplot(df,x='Horsepower',y='Miles_per_Gallon', color='Origin')