import pandas as pd
import numpy as np
from plotnine import ggplot, aes, geom_point
aes
In [1]:
Mapping variables to the visual properties of a plot.
In [2]:
= pd.DataFrame({
df "col1": np.arange(11),
"col2": np.arange(11)
})
(="col1", y="col2"))
ggplot(df, aes(x+ geom_point()
)
In [3]:
(="col1", y="col2 ** 2"))
ggplot(df, aes(x+ geom_point()
)
In [4]:
(="col1", y="np.square(col2)"))
ggplot(df, aes(x+ geom_point()
)
The first two positional arguments are x
and y
aesthetics. Any other aesthetic must be mapped with a keyword argument.
In [5]:
("col1", "np.square(col2)", color="col2"))
ggplot(df, aes(+ geom_point(size=3)
)