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))






+ Recent posts