1

I´d like to reproduce the simple grouped violin plot from the tutorial here:

http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization

It uses the built in ToothGrowth dataset so it should be easily reproducible.

I use this code (in a blank R script after restarting RScript Software)

# Change violin plot colors by groups
ggplot(ToothGrowth, aes(x=dose, y=len, fill=supp)) +
  geom_violin()

And I get this result, totally different from the tutorial example. My Result: My Result

Tutorial Example = lower picture Tutorial example

Everything else up to this point in the Tutorial was easily reproducible and a great help in learning :) So what is my mistake? I want it to look like the example in the tutorial.

Interestingly I can easily reproduce the same kind of violin plot using the code provided as an example in this question

Split violin plot with ggplot2

My Specs: Win7 64bit (German Version, Software all english) - RStudio newest Version 1.0.143 - R newest Version Version 3.40.7034.0 -

Taya
  • 135
  • 5
  • 2
    The tutorial example seems to have been produced with `ggplot(ToothGrowth, aes(x=factor(dose), y=len, fill=supp)) + geom_violin()` – Andrew Gustar May 26 '17 at 14:36
  • 1
    Thanks, this works! Didn´t see the difference at first ;) If you make it an answer I can accept it :) – Taya May 26 '17 at 20:02

1 Answers1

2

The tutorial example seems to have been produced with

ggplot(ToothGrowth, aes(x=factor(dose), y=len, fill=supp)) + geom_violin()
Andrew Gustar
  • 17,295
  • 1
  • 22
  • 32