Challenge: can you make a violin plot instead? (hint:
?geom_violin
)
ggplot(expt1, aes(genotype, days.to.flower)) +
geom_boxplot()
## Warning: Removed 83 rows containing non-finite values (stat_boxplot).
Challenge: can you modify this plot so that the points appear on top of the boxplots rather than behind them?
ggplot(expt1, aes(genotype, rosette.leaf.num)) +
geom_boxplot() +
geom_jitter()
## Warning: Removed 95 rows containing non-finite values (stat_boxplot).
## Warning: Removed 95 rows containing missing values (geom_point).
Challenge: say we are particularly interested in the relationship between number of rosette leafs and blade length in mm per genotype.
Visualize this relationship with a scatter plot (
geom_point()
) betweenblade.length.mm
androsette.leaf.num
and colour the points bygenotype
.What happens if you colour the points by
days.to.bolt
?
ggplot(expt1, aes(blade.length.mm, rosette.leaf.num, colour = genotype)) +
geom_point()
## Warning: Removed 333 rows containing missing values (geom_point).
If we colour the points by days.to.bolt
the colour scale is continuous rather than discrete (because days.to.bolt
is a numeric variable):
ggplot(expt1, aes(blade.length.mm, rosette.leaf.num, colour = days.to.bolt)) +
geom_point()
## Warning: Removed 333 rows containing missing values (geom_point).
Challenge: In the previous graph, colouring the genotype is redundant with the facetting. Can you think of a more useful way to colour the points?
ggplot(expt1, aes(blade.length.mm, rosette.leaf.num, colour = fluctuation)) +
geom_point() +
facet_wrap( ~ genotype)
## Warning: Removed 333 rows containing missing values (geom_point).
Challenge: Can you modify the previous graph to facet the data by the
fluctuation
treatment (as rows) andday.length
(as columns) and colour the points by genotype.
ggplot(expt1, aes(blade.length.mm, rosette.leaf.num, colour = genotype)) +
geom_point() +
facet_grid(day.length ~ fluctuation)
## Warning: Removed 333 rows containing missing values (geom_point).
Challenge: Can you produce a graph similar to .
Hint: facet the plot by
day.length
andtemperature
and fill the boxplots byfluctuation
.
ggplot(expt1, aes(genotype, days.to.bolt, fill = fluctuation)) +
geom_boxplot() +
facet_grid(day.length ~ temperature)