我想问一下,如果有人知道r package ggvis中关于轴格式的答案。 我使用%轴格式,但我想根据CVaR的传播添加som小数位。 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) }
谢谢
答案 0 :(得分:1)
您可以在此处阅读有关格式化的信息: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%')