ggplot
II
Last time we introduced the ggplot
package (philosophy).
Identify a “research” topic in an area of personal interest.
Considering some research topic in an area of personal interest.
We will revisit with our “graph groups” from a few weeks ago.
ggplot()
tools, if possible.These will be shared by the end of the week to D2L and used as opening slides next week for a brief, relatively informal, Data Viz “Fashion Show”.
Brief content reminder, a break to work, then “normal class”.
The idea of annotation as a layer was another fundamental feature of the “grammar”.
labs()
(axes and titles)One more helpful thing to consider at this point would be to use
as the analog to mtext()
from base R.
With this you can do meaningful annotation.
geom_text()
(in-plot text)After that you might need to annotate (using text) within the space of the graph.
label = ...
should be a variable name.hjust = ...
with 0 (left-justified) or 1 (right-justfied) as options.nudge_x = ...
(or _y
) as numbers for text placement adjustment.parse = ...
with TRUE
to interpret text as (porentially)hopefully) properly-formatted mathematical expressions.Used in combination with geom_text()
, geom_label()
may make text more readable by providing a “background”.
annotate()
(open-ended)Alternatively, annotate()
with a variety of options to do many things1.
Here "geom"
could be replaced (literaly) by one of,
"text"
, with x
, y
, and label
"rect"
, with “corners” fully-specified by xmin = ..., xmax = ..., ymin = ..., ymax = ...
"segments"
, with “endpoints” fully-specified by x = ..., xend = , y = ..., yend = ...
"point"
, with x
, y
, and likely color
and size
Including just the list of "geom"
choices that are compatible with annotate()
(e.g., "curve"
for curved annotation arrows), there are a lot of special functions for individual tasks.
Feel free to start browsing online resources like https://ggplot2-book.org/ (if you haven’t been) for examples.