Display :: theme ——————————————————–

Published onesixx on

 

Theme은 데이터와 상관없기 때문에, geom 객체가 그려지는데 영향이 없다. – font, panel, background, ticks, 띠…

4가지 구성요소

elements

plot.title요소 , axis.ticks,x , legend.key.height

elements function()

element_text()

theme function()

기본 테마 요소 재정의

themes

미리 정해진 theme 사용

theme_grey()

 

 

plot title 추가

Axis와 legend 레이블 개선

color scale 조정

(p <- mpg %>% ggplot(aes(cty,hwy)) + 
                geom_jitter(aes(color=factor(cyl))) + 
                geom_abline()
)

(p <- p + labs(title="highly correlated between City and Highway mileage",
               x="City mileage", y="Highway mileage", color="Cylinders") +
    scale_color_brewer(type="seq", palette="Spectral")
)

p + theme_bw()+
    theme(plot.title=element_text(face="bold", size=16, hjust=1, color="red"),
          legend.background=element_rect(fill="grey66", size=0.5, color="grey66"),
          legend.justification=c(0,1), legend.position=c(0,1),
          axis.ticks=element_line(color="grey77", size=0.6),
          panel.grid.major=element_line(color="grey77", size=0.6),
          panel.grid.minor=element_blank()
          )

 

 

=——————————

X축 표기값 반시계방향으로 90 꺽고, text 미세조정

credit %>%  ggplot(aes(x=CreditAmount, y=Credit)) +
    geom_point(position = position_jitter(height = .2)) +
    xlab("Credit Amount") + theme(axis.text.x=element_text(angle=90, hjust=1, vjust=.5)) 

 

 

5. Theme

예) 축(axis), 레전드(legend), 레이블(lable), 그리드(grid) 라인들 등 

theme Modify components of a theme
theme_bw Complete themes
theme_classic Complete themes
theme_dark Complete themes
theme_get Get, set, and modify the active theme
theme_gray Complete themes
theme_grey Complete themes
theme_light Complete themes
theme_linedraw Complete themes
theme_minimal Complete themes
theme_replace Get, set, and modify the active theme
theme_set Get, set, and modify the active theme
theme_update Get, set, and modify the active theme
theme_void Complete themes

xlab Modify axis, legend, and plot labels

ylab Modify axis, legend, and plot labels

labeller Construct labelling specification
labellers Useful labeller functions
label_both Useful labeller functions
label_bquote Label with mathematical expressions
label_context Useful labeller functions
label_parsed Useful labeller functions
label_value Useful labeller functions
label_wrap_gen Useful labeller functions
labs Modify axis, legend, and plot labels

Categories: ggplot2

onesixx

Blog Owner

Leave a Reply

Your email address will not be published.