lets-plot
lets-plot copied to clipboard
The tooltip format with `{}` in the pattern ignores the default formatting
When using the '{}' construction in the format pattern, a string representation of the value is substituted into the result. It would be better to use the default formatted value.
For example, we want to change the content of the axis tooltip by adding a symbol to the value:
N = 21
x = [v for v in range(N)]
y0 = [pow(10, v / 10.) for v in range(N)]
y1 = [v * 5 for v in range(N)]
formula = ['10^(x/10)'] * N + ['5*x'] * N
data = dict(x=x * 2, y=y0 + y1, formula=formula)
ggplot(data) + geom_point(aes('x', 'y', color='formula', size='formula')) + scale_size_manual(values=[7, 3]) + scale_y_log10()
- default axis tooltip:
-
after specifying the format for the y-axis tooltip:
tooltips=layer_tooltips().format('^y', '{} %'))
-
Expected:
1.58 %
Internal use: https://forum.datalore-plot.jetbrains-boston.com/t/tooltips-config/114/79