ggvis icon indicating copy to clipboard operation
ggvis copied to clipboard

layer_smooths not working with size property

Open tklebel opened this issue 10 years ago • 1 comments

When trying to add layer_smooths/layer_model_predictions to a plot where size is set an error occurs.

library(ggvis)
library(dplyr)

df <- as_data_frame(list(x = c(1:3),
                         y = c(1:3),
                         z = c(1:3)))

# works
df %>% 
  ggvis(~x, ~y) %>% 
  layer_points()

# works
df %>% 
  ggvis(~x, ~y) %>% 
  layer_points() %>%
  layer_model_predictions(model = "lm")

# works
df %>% 
  ggvis(~x, ~y, size = ~z) %>% 
  layer_points()

# doesn't work
df %>% 
  ggvis(~x, ~y, size = ~z) %>% 
  layer_points() %>% 
  layer_model_predictions(model = "lm")
Error in eval(expr, envir, enclos) : Object 'z' not found

tklebel avatar Aug 08 '15 16:08 tklebel

I can't speak for why it doesn't work, but layer_model_predictions() doesn't support the size property. What you can do is this:

df %>% 
    ggvis(~x, ~y) %>% 
    layer_model_predictions(model = "lm") %>%
    layer_points(size = ~z)

joshmorel avatar Jan 23 '16 20:01 joshmorel