/* flexbox를 이용한 기본형 */

.box{
display: flex;
justify-content: center;  /*content가 여러 개일 때는 space-between이나 space-around 등을 선택*/
align-items: center;

/* box 안에 content 중 몇 개만 정렬하고 싶을 때 각각 padding을 이용하여 위아래에 같은 공간을 둘 수 있음
 단, padding 때문에 block이 커지므로 box-sizing: border-box를 같이 쓰도록 하자*/

*{
box-sizing: border-box;
}

.box2{
display: flex;
justify-content: center;
padding: 40px 0px;
}

/* fixed된 block을 가운데 두고 싶을 때
상하 margin을 0, 좌우 margin을 auto로 해놓고, 좌우를 0으로 해놓으면 가운데에 놓임*/

.box2{
margin: 0 auto;
left: 0;
right: 0;
}

 

 

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