1. Title
... + ggtitle('title') # or labs(title = 'title', ...)
# title appears at topright by default. To move title to center
... + theme(plot.title = element_text(hjust = 0.5))
2. labels
... + xlabs('label') + ylabs('label') # or labs(x = 'xlab', y = 'ylab')
3. line
... + geom_line(size = 2, color = '') # just connect points with line
... + geom_abline(size = 2, color = '') # draw regression line
... + geom_vline(size = 2, color = '') # draw vertical line
... + geom_hline(size = 2, color = '') # draw horizontal line
4. draw dynamic plot with manipulate function
myplot <- function(dynamic variable){
d <- data.frame(..., temp = dynamic variable, ...),
g <- ggplot(d, aes(...))
g <- g + geom_line()
...
g
}
manipulate(myplot(dynamic variable), slider(min, max, step = 1))
'Programming' 카테고리의 다른 글
가상환경을 위해 WSL(windows subsystem for Linux) 깔아보기 (0) | 2020.05.06 |
---|---|
html, css 가운데 정렬 총 정리 (0) | 2020.04.11 |
[R] Efficient R programming practice (0) | 2018.12.16 |
[R] ggplot error message (0) | 2018.12.06 |
[R] ggplot coloring manual (0) | 2018.12.06 |