What is ggplot()
and why is it awesome?
Think of a plot / graph as having multiple layers
..
Source: blog/sharpsightlabs.com:
Source: blog/sharpsightlabs.com:
There’s many more geoms in the ggplot cheatsheet!
Let us quickly see an animation of empty plot, adding axes, adding data for the histogram
ggplot()
callmapping = aes()
geom_point()
geom_line()
This hides the plot and needs to be called with print()
Hey, where’s my plot gone? 🤔
print
itcolour = col_name
in aes()
colour = 'red'
- Doesn’t workcolour = 'red'
really work?colour = 'red'
outside aes()
Hint: There should be no legend!
How to train your ggplot::
theme
Please download the _class8_ggplot_worksheet.Rmd or the .R
file with the same name from the syllabus website
the .Rmd
will make it easier to read the prompts and run code by clicking on the “play” button (run current chunk) for each chunk
If you are not comfortable with this, you can use the .R
file instead with the same content
coming later..?