layer_tooltips#
- layer_tooltips(variables=None) LayerTooltipsSpec#
Create layer tooltips specification.
- Parameters:
- variableslist of str, optional
List of variable names to be shown in the tooltips. Each variable will be placed on its own line. If None (default), the list of variables is defined automatically based on the layer aesthetic mappings.
- Returns:
LayerTooltipsSpecLayer tooltips specification.
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n = 100 5np.random.seed(42) 6data = { 7 'id': np.arange(n), 8 'x': np.random.normal(size=n), 9 'y': np.random.normal(size=n), 10 'c': np.random.choice(['a', 'b'], size=n), 11 'w': np.random.randint(1, 11, size=n) 12} 13ggplot(data, aes('x', 'y')) + \ 14 geom_point(aes(color='c', size='w'), \ 15 tooltips=layer_tooltips().line('@c "@id"') 16 .line('---') 17 .format('@y', '.2f') 18 .line('(x, y)|(^x, @y)') 19 .line('@|@w')) + \ 20 scale_size(range=[2, 4])
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n = 100 5np.random.seed(42) 6data = { 7 'x': np.random.normal(size=n), 8 'y': np.random.normal(size=n), 9 'c': np.random.randint(10, size=n) 10} 11ggplot(data, aes('x', 'y')) + \ 12 geom_point(aes(color='c'), tooltips='none')