2 Individual geoms
2.1 Basic plot types
Q1: What geoms would you use to draw each of the following named plots?
- Scatterplot
- Line chart
- Histogram
- Bar chart
- Pie chart
A:
Scatterplot:
geom_point()Line chart:
geom_line()Histogram:
geom_histogram()Bar chart:
geom_bar()Pie chart:
geom_bar() + coord_polar()
Q2: What’s the difference between geom_path() and geom_polygon()? What’s the difference between geom_path() and geom_line()?
A: geom_polygon() is very similar to geom_path() except that the start and end points are connected and the inside is coloured by fill.
geom_path() connects the observations in the order in which they appear in the data, but geom_line() connects them in order of the variable on the x-axis.
Q3: What low-level geoms are used to draw geom_smooth()? What about geom_boxplot() and geom_violin()?
A:
geom_smooth():geom_path(), andgeom_area().geom_violin():geom_area(), andgeom_path().