I'm trying to use ggplot
to create a violin plot where instead of the widths of the violins being controlled by a density function, they directly represent the count of relevant elements.
I think this can be accomplished through setting geom_violin(stat="identity")
, but R then complains
> ggplot(allData, aes(x = tool, y = length)) + geom_violin(stat="identity")
Warning: Ignoring unknown parameters: trim, scale
Error in eval(substitute(list(...)), `_data`, parent.frame()) :
object 'violinwidth' not found
Trying to add aes(violinwidth=0.2*count)
, as this answer suggests, gives
> ggplot(allData, aes(x = tool, y = length)) + geom_violin(stat="identity", aes(violinwidth=0.2*count))
Warning: Ignoring unknown parameters: trim, scale
Warning: Ignoring unknown aesthetics: violinwidth
Error in FUN(X[[i]], ...) : object 'count' not found
And while I can set violinwidth
to just a constant, this makes the violins just rectangles. How can I fix this?