library(ggplot2)
load("data/new_metadata.RData")
ggplot(new_metadata) +
geom_point(aes(x = age_in_days, y= samplemeans, color = genotype,
shape=celltype), size=2.25) +
theme_bw() +
theme(axis.title = element_text(size=rel(1.5)))
Exercise-1
Exercise-1: Theme-ing
Let’s return to our scatterplot:
Basic
1. The current axis label text defaults to what we gave as input to geom_point
(i.e the column headers). We can change this by adding additional layers called xlab()
and ylab()
for the x- and y-axis, respectively. Add these layers to the current plot such that the x-axis is labeled “Age (days)” and the y-axis is labeled “Mean expression”.
2. Use the ggtitle
layer to add a plot title of your choice.
3. Add the following new layer to the code chunk `theme(plot.title=element_text(hjust=0.5))`.
- What does it change?
- How many theme() layers can be added to a ggplot code chunk, in your estimation?
The materials in this lesson have been adapted from work created by the (HBC)\](http://bioinformatics.sph.harvard.edu/) and Data Carpentry (http://datacarpentry.org/). These are open access materials distributed under the terms of the [Creative Commons Attribution license](https://creativecommons.org/licenses/by/4.0/) (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.