kassambara / ggpubr

'ggplot2' Based Publication Ready Plots
https://rpkgs.datanovia.com/ggpubr/
1.13k stars 165 forks source link

ggvoilin crashes when scales is set to free, free_x or free_y #398

Open dansmith01 opened 3 years ago

dansmith01 commented 3 years ago

When I attempt to run ggvoilin(..., scales="free"), it crashes with the following error message:

ggviolin(ToothGrowth, y = "len", scales = "free")
Error in eval(substitute(list(...)), `_data`, parent.frame()) : 
  object 'violinwidth' not found

Obviously there's no reason to set scales= in the code above; it's simply a minimal reproducible example. It still crashes when used in a more appropriate context. Here are some similar commands that run fine:

ggviolin(ToothGrowth, y = "len")
ggboxplot(ToothGrowth, y = "len", scales = "free")
ggstripchart(ToothGrowth, y = "len", scales = "free")
ggdotplot(ToothGrowth, y = "len", scales = "free")
dansmith01 commented 3 years ago

Interestingly, this works:

ggviolin(ToothGrowth, "dose", "len") %>% facet("supp", scales = "free")

But this is broken:

ggviolin(ToothGrowth, "dose", "len", facet.by = "supp", scales = "free")
Error in eval(substitute(list(...)), `_data`, parent.frame()) : 
  object 'violinwidth' not found

Any idea where violinwidth is referenced, @kassambara ? I did a text search of the codebase and it didn't pop up anywhere. If you can point me to it, I might be able to submit a fix.