ggthemes 예제들

ggthemes 참고용 이미지들…

패키지에서 제공한 예제 코드들에 대해서 실행한 결과물을 함께 올렸다.
필요할때 찾아서 쓰자!

개인적으론 theme_economist가 제일 맘에 드네..

library(ggthemes)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
(qplot(carat, price, data = dsamp, colour = clarity) + theme_solarized() + scale_colour_solarized("blue"))

plot of chunk unnamed-chunk-1

## Dark version
(qplot(carat, price, data = dsamp, colour = clarity) + theme_solarized(light = FALSE) + 
    scale_colour_solarized("blue"))

plot of chunk unnamed-chunk-1



dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
q <- (qplot(carat, price, data = dsamp, colour = clarity) + ggtitle("Diamonds Are Forever"))

## Standard
q + theme_economist() + scale_colour_economist()

plot of chunk unnamed-chunk-1


## Stata colors
q + theme_economist(stata = TRUE) + scale_colour_economist(stata = TRUE)

plot of chunk unnamed-chunk-1


## Darker plot region
q + theme_economist(dkpanel = TRUE) + scale_colour_economist(stata = TRUE)

plot of chunk unnamed-chunk-1


## Darker plot region is best for for facets
dkblue <- ggthemes_data$economist$fg["blue_dark"]
(ggplot(data = dsamp, aes(x = carat, y = price)) + geom_point(colour = dkblue) + 
    facet_grid(. ~ cut) + theme_economist(dkpanel = TRUE))

plot of chunk unnamed-chunk-1


##' ## Change axis lines to vertical
(q + theme_economist(horizontal = FALSE) + scale_colour_economist() + coord_flip())

plot of chunk unnamed-chunk-1


## White panel/light gray background
(q + theme_economist_white() + scale_colour_economist())

plot of chunk unnamed-chunk-1


## All white variant
(q + theme_economist_white(gray_bg = FALSE) + scale_colour_economist())

plot of chunk unnamed-chunk-1

## Not run: The Economist uses ITC Officina Sans



dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
# Old line color palette
(qplot(carat, price, data = dsamp, colour = clarity) + theme_excel() + scale_colour_excel())

plot of chunk unnamed-chunk-1

# Old fill color palette
(ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() + scale_fill_excel("fill") + 
    theme_excel())

plot of chunk unnamed-chunk-1



dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
(qplot(carat, price, data = dsamp, colour = clarity) + theme_few() + scale_colour_few())

plot of chunk unnamed-chunk-1

(qplot(carat, price, data = dsamp, colour = clarity) + theme_few() + scale_colour_few("dark"))

plot of chunk unnamed-chunk-1

(ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() + theme_few() + scale_fill_few("light"))

plot of chunk unnamed-chunk-1



dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
(d <- qplot(carat, price, data = dsamp, colour = clarity) + theme_igray())

plot of chunk unnamed-chunk-1

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
q1 <- (qplot(carat, price, data = dsamp, colour = clarity) + ggtitle("Diamonds"))
q2 <- (qplot(carat, price, data = dsamp) + facet_wrap(~clarity) + ggtitle("Diamonds"))
q1mono <- (qplot(carat, price, shape = clarity, color = clarity, data = dsamp) + 
    scale_shape_stata() + ggtitle("Diamonds"))
## s2color
(q1 + theme_stata() + scale_colour_stata("s2color"))

plot of chunk unnamed-chunk-1

(q2 + theme_stata())

plot of chunk unnamed-chunk-1

## s2mono
(q1mono + theme_stata("s2mono") + scale_colour_stata("mono"))

plot of chunk unnamed-chunk-1

(q2 + theme_stata("s2mono"))

plot of chunk unnamed-chunk-1

## s1color
(q1 + theme_stata("s1color") + scale_colour_stata("s1color"))

plot of chunk unnamed-chunk-1

(q2 + theme_stata("s1color"))

plot of chunk unnamed-chunk-1

## Not run: s1rcolor
(q1 + theme_stata("s1rcolor") + scale_colour_stata("s1rcolor"))

plot of chunk unnamed-chunk-1

(ggplot(dsamp, aes(x = carat, y = price)) + geom_point(colour = "white") + facet_wrap(~clarity) + 
    scale_colour_stata("s1rcolor") + ggtitle("Diamonds"))

plot of chunk unnamed-chunk-1

## s1mono
(q1mono + theme_stata("s1mono") + scale_colour_stata("mono"))

plot of chunk unnamed-chunk-1

(q2 + theme_stata("s1mono"))

plot of chunk unnamed-chunk-1



# with ticks and range frames
(ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rangeframe() + theme_tufte())

plot of chunk unnamed-chunk-1

# with geom_rug
(ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rug() + theme_tufte(ticks = FALSE))

plot of chunk unnamed-chunk-1

## Not run: Using the Bembo serif family
library(extrafont)
(ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rangeframe() + theme_tufte(base_family = "BemboStd"))

plot of chunk unnamed-chunk-1

## Using the Gill Sans sans serif family
(ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rangeframe() + theme_tufte(base_family = "GillSans"))

plot of chunk unnamed-chunk-1




(qplot(hp, mpg, data = mtcars, geom = "point") + scale_colour_wsj("colors6", 
    "") + ggtitle("Diamond Prices") + theme_wsj())

plot of chunk unnamed-chunk-1

## Use a gray background instead
(qplot(hp, mpg, data = mtcars, geom = "point") + scale_colour_wsj("colors6", 
    "") + ggtitle("Diamond Prices") + theme_wsj(color = "gray"))

plot of chunk unnamed-chunk-1

CC BY-NC 4.0 ggthemes 예제들 by from __future__ import dream is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.