Skip to content

Instantly share code, notes, and snippets.

@alex-ketch
Created April 16, 2020 20:47
Show Gist options
  • Save alex-ketch/4391125dbbd481dda7c6eb32784f4f00 to your computer and use it in GitHub Desktop.
Save alex-ketch/4391125dbbd481dda7c6eb32784f4f00 to your computer and use it in GitHub Desktop.
Stencila tutorial
library(ggplot2)
# Order by highway MPG
mpg$class = with(
mpg,
reorder(class, hwy, median)
)
ggplot(mpg, aes(
x=class,
y=hwy,
# Use vehicle class for color
fill = class
)) +
geom_violin() +
theme(legend.position="none") +
xlab("Vehicle class") +
ylab("Highway MPG")
@alex-ketch
Copy link
Author

library(ggplot2)

# Order by highway MPG
mpg$class = with(
  mpg,
  reorder(class, hwy, median)
)
ggplot(mpg, aes(
 x=class,
 y=hwy,
)) +
geom_violin() +
theme(legend.position="none")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment