layer_key#
- layer_key(label, group=None, *, index=None, **kwargs)#
Configure custom legend.
- Parameters:
- labelstr
Text for the element in the custom legend.
- groupstr, default=’manual’
Group name by which elements are combined into a legend group.
- indexint
Position of the element in the custom legend.
- kwargs
A list of aesthetic parameters to use in the custom legend.
- Returns:
- FeatureSpec
Custom legend specification.
Notes
The group name specified with the group parameter can be used in the labs() and guides() functions to further customize the display of this group (e.g. change its name). In particular, items in the ‘manual’ group will be displayed without a title unless you change it manually.
If you set the same group and label for a legend element in different layers, they will merge into one complex legend element.
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n = 10 5np.random.seed(42) 6x = list(range(n)) 7y = np.random.uniform(size=n) 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + \ 9 geom_point(color='red', manual_key=layer_key("point", shape=21)) + \ 10 geom_line(color='blue', linetype=2, manual_key=layer_key("line", linetype=1))