vegawidget / virgo

A DSL for layered grammar of interactive graphics in R

Home Page:https://vegawidget.github.io/virgo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Odd `mark_density()`

earowang opened this issue · comments

penguins %>% 
  vega(enc(x = body_mass_g, colour = species)) %>% 
  mark_density()

Yeah this one definitely doesn't work how I expected / is broken try:

penguins %>% 
  vega(enc(x = body_mass_g, colour = species)) %>% 
  mark_density()

Missing values causing issues again.
This gives the expected result:

penguins %>% 
    filter(!is.na(body_mass_g)) %>% 
    vega(enc(x = body_mass_g, colour = species)) %>% 
    mark_density()
    
 penguins %>% 
    filter(!is.na(body_mass_g)) %>% 
    vega(enc(x = body_mass_g)) %>% 
    mark_density() 

😢 Now this mtcars not working as expected.

mtcars %>%
  mutate(cyl = factor(cyl)) %>%
  vega(encoding = enc(x = wt, colour = cyl)) %>%
  mark_density()

image

it seems like an issue with the stacking again? here's ggplot2 for reference
image

I've removed "stack" = zero". The default in ggplot2 is "identity". In vegalite, stack = zero means stacked density?

image

image

image

Seems not working for mtcars when stacking.
image

maybe the default bandwidth is off? maybe this more reason for us to compute these things on the r side haha

Should position = "stack" be the default?