theme
Theme elements are the non-data parts of your plot (e.g., text, These can be accessed using the theme
function:
basePlot + theme(element.name = element_function())
Where element.name
refers to the element of the graph (e.g., axis.ticks for the tick marks), and the element_function
controls what aspect of it is going to be changed (e.g., line width).
theme
element_text()
controls text face, color, size, angle, etc.
element_line()
controls line color, linewidth, and linetype
element_rect()
controls rectangular areas fill and border line
element_blank()
controls whether an element is drawn or not
Try customizing your graph using the following (use ? to get function help).
Element | Function | Modifies |
---|---|---|
plot.background | element_rect | Plot background area |
plot.title | element_text | Plot title |
You can modify just one axis by adding .x
or .y
to your element name.
You can remove an element by using element_blank()
Try customizing your graph using the following (use ? to get function help).
Element | Function | Modifies |
---|---|---|
axis.line | element_line() | Axis line |
axis.text | element_text() | Text at tick marks |
axis.title | element_text() | Axis title |
axis.ticks | element_line() | Tick marks |
axis.ticks.length | unit() | Length of tick marks |
Try customizing your graph using the following (use ? to get function help).
Element | Function | Modifies |
---|---|---|
panel.background | element_rect() | Panel background |
panel.grid.major | element_line() | Major gridlines |
panel.grid.minor | element_line() | Minor gridlines |
Try customizing your graph using the following (use ? to get function help).
Element | Function | Modifies |
---|---|---|
legend.background | element_rect() | legend background |
legend.key | element_rect() | background of legend keys |
legend.text | element_text() | legend labels |
legend.title | element_text() | legend name |
Use ggsave to output to a file and control its size
ggsave("baseplot.pdf",basePlot,width=6,height=4,units="in")
The Lab Exercise for tomorrow will be a short quiz on Canvas dealing with different parts of the course. You will not need to be in the Lab to complete this assignment.
Lab time tomorrow will be devoted to completing the final project.
I will be in the Data Lab from 4PM to 9PM to consult on final project questions.