带有百分比和小数位的 r ggvis 轴格式

r ggvis axis format with percentage and decimal places

我想问一下,是否有人知道有关 r 包 ggvis 中轴格式的答案。 我使用的是 % 轴格式,但我想根据 CVaR 的分布添加一些小数位。 image here 这是我的代码:

Datovka %>% ggvis(x = ~yShort,y = ~xShort,strokeWidth:=1, stroke:="blue",  strokeWidth.hover := 3) %>% layer_paths() %>% layer_paths(x = ~yNoShort, y = ~xNoShort, data = DatovkaNoShort , stroke :="green",strokeWidth:=1, strokeWidth.hover := 3)  %>%
  layer_points(~vol,~r,data = vynosyR, fill := ~isinP, key := ~id , size := 60, size.hover :=120 ) %>%
  # hide_legend("fill") %>%
  add_tooltip(all_values, "hover") %>%
  add_axis("x", title = "CVaR",format = "%" , title_offset = 50) %>%
  add_axis("y", title = "Expected return", format = "%" , title_offset = 50) %>%
  scale_numeric("y", nice = FALSE, clamp = TRUE)  %>%
  scale_numeric("x", nice = FALSE, clamp = TRUE) }

谢谢

您可以在此处阅读有关格式化的信息:https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md

df <- data.frame(x = seq(0.1, 1, 0.1) / 100, y = runif(10))
df %>% ggvis(~x, ~y) %>% layer_paths() %>% add_axis("x", format = '.2%')