Page last updated: 04 May, 2019

 

Examples

Violin plot

##### Violin plot
ggplot(data = movies, 
       aes(x = factor(Genre), y = rating)) + 
  xlab("") + 
  ylab("Rating (out of 10") +
  geom_violin(color = discrete_wes_pal[1],
              fill = discrete_wes_pal[1], 
              alpha = 0.8) +
  stat_summary(fun.y = median, geom ='point') +
  my_theme() +
  theme(
    axis.text.x = element_text(angle = 90,
                               hjust = 1,
                               vjust = 0.5),
    axis.text.y = element_text(hjust = 1,
                               vjust = 0.5)
    )

LS0tCnRpdGxlOiAiVmlvbGluIHBsb3RzIgpvdXRwdXQ6CiAgaHRtbF9kb2N1bWVudDoKICAgIHRvYzogZmFsc2UKICAgIG51bWJlcl9zZWN0aW9uczogZmFsc2UKICAgIGRmX3ByaW50OiBwYWdlZAogICAgY29kZV9kb3dubG9hZDogdHJ1ZQogICAgaGlnaGxpZ2h0ZXI6IG51bGwKLS0tCgpgYGB7ciBzZXR1cCwgZXZhbD1UUlVFLCBpbmNsdWRlPUZBTFNFLCBlY2hvPUZBTFNFLCBlcnJvcj1GQUxTRSwgbWVzc2FnZT1GQUxTRSwgd2FybmluZz1GQUxTRSwgY2FjaGU9VFJVRSwgZmlnLmFsaWduPSdjZW50ZXInLCBjb21tZW50PSIifQpjaG9vc2VDUkFObWlycm9yKGdyYXBoaWNzPUZBTFNFLCBpbmQ9MTMzKQpzb3VyY2UoInNvdXJjZS9wbG90cy1vdmVydmlldy5SIikKYGBgCl9fXwoKUGFnZSBsYXN0IHVwZGF0ZWQ6IGByIGZvcm1hdChTeXMudGltZSgpLCAnJWQgJUIsICVZJylgCgpcICAKCiMgRXhhbXBsZXMgeyN2aW9saW5fcGxvdHMgLnRhYnNldH0KCiMjIFZpb2xpbiBwbG90IHsjdmlvbGlufQpgYGB7ciB2aW9saW4sIGV2YWw9VFJVRSwgaW5jbHVkZT1UUlVFLCBlY2hvPVRSVUUsIGVycm9yPUZBTFNFLCBtZXNzYWdlPUZBTFNFLCB3YXJuaW5nPUZBTFNFLCBj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