lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

The tooltip format with `{}` in the pattern ignores the default formatting

Open OLarionova-HORIS opened this issue 4 years ago • 1 comments

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:
Screenshot 2021-11-26 at 14 42 30
  • after specifying the format for the y-axis tooltip:
    tooltips=layer_tooltips().format('^y', '{} %')) Screenshot 2021-11-26 at 14 42 43

  • Expected: 1.58 %

OLarionova-HORIS avatar Nov 26 '21 12:11 OLarionova-HORIS

Internal use: https://forum.datalore-plot.jetbrains-boston.com/t/tooltips-config/114/79

alshan avatar Mar 30 '22 16:03 alshan