I want to ask, if someone knows answer regarding axis format in r package ggvis. I am using % axis format, but I want to add som decimal places depending on spread of CVaR. image here Here is my code :
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) }
Thank you
You can read about formating here: 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%')