aes#
- aes(x=None, y=None, **kwargs)#
Define aesthetic mappings.
- Parameters:
- x, y, …
Aesthetic mappings. Name-value pairs specifying which data variables to use for each aesthetic. The names for x and y aesthetics are typically omitted because they are so common; all other aesthetics must be named. The specific list of supported aesthetics differs by geometry type.
- groupstr or list, optional
Data grouping control (not a true aesthetic). Use a variable name to group by that variable, a list of variables to group by their interaction, or an empty list to disable all grouping.
- Returns:
FeatureSpecAesthetic mapping specification.
Notes
Generate aesthetic mappings that describe how variables in the data are projected to visual properties (aesthetics) of geometries. This function also standardizes aesthetic names by, for example, converting colour to color.
Aesthetic mappings are not to be confused with aesthetic settings; the latter is used to set aesthetics to some constant values, e.g., make all points red in the plot. If one wants to make the color of a point depend on the value of a variable, he/she should project this variable to the color aesthetic via aesthetic mapping.
Data Grouping
The
groupparameter is not a true aesthetic but controls how data is grouped for visualization:- Default Grouping Behavior:
Lets-Plot automatically groups data by discrete variables mapped to aesthetics like
color,shape,linetype, etc. This creates separate visual elements (lines, paths, polygons) for each unique combination of these variables.- Explicit Group Control:
Use
group='variable_name'to group only by that specific variable, overriding default groupingUse
group=['var1', 'var2', ...]to group by the interaction of multiple variablesUse
group=[]to disable all the grouping completely
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n = 100 5np.random.seed(42) 6x = np.random.uniform(-1, 1, size=n) 7y = 25 * x ** 2 + np.random.normal(size=n) 8c = np.where(x < 0, '0', '1') 9ggplot({'x': x, 'y': y, 'c': c}) + \ 10 geom_point(aes('x', 'y', color='y', shape='c', size='x')) + \ 11 geom_smooth(aes(x='x', y='y'), deg=2, size=1)
1from lets_plot import * 2LetsPlot.setup_html() 3ggplot() + geom_polygon(aes(x=[0, 1, 2], y=[2, 1, 4]), \ 4 color='black', alpha=.5, size=1)