Last data update: 2014.03.03

R: The Default Theme
theme_pubR Documentation

The Default Theme

Description

After loading the SciencesPo package, this theme will be set to default for all subsequent graphs made with ggplot2.

Usage

theme_pub(legend = "bottom", base_size = 13, base_family = "",
  horizontal = FALSE, line_width = 0.5, axis_line = FALSE)

Arguments

legend

Enables to set legend position, default is "bottom".

base_size

Overall font size. Default is 14.

base_family

Default font family.

horizontal

Logical. Horizontal axis lines?

line_width

Default line size.

axis_line

Enables to set x and y axes.

Value

The theme.

See Also

theme, theme_538, theme_blank.

Examples

PreviewTheme()+theme_pub()

ggplot(diamonds,aes(cut, group=1)) + geom_bar()+
geom_freqpoly(stat="count",size=2) + theme_pub(line_width=2.5)

ggplot(diamonds,aes(cut, group=1)) +
geom_bar()+
geom_freqpoly(stat="count",size=2) +
theme_pub(base_family='serif')

dat <- data.frame()
for(i in 1:4)
dat <- rbind(dat, data.frame(set=i, x=anscombe[,i], y=anscombe[,i+4]))

ggplot(dat, aes(x, y)) + geom_point(size=5, color="red",
fill="orange", shape=21) +
geom_smooth(method="lm", fill=NA, fullrange=TRUE) +
facet_wrap(~set, ncol=2) +
theme_pub(base_family='serif')


ggplot(dat, aes(x, y)) + geom_point(size=5, color="red",
fill="orange", shape=21) +
geom_smooth(method="lm", fill=NA, fullrange=TRUE) +
facet_wrap(~set, ncol=2) +
theme_bw() +
theme(plot.background=element_rect(fill="#f7f7f7")) +
theme(panel.background=element_rect(fill="#f7f7f7")) +
theme(panel.grid.minor=element_blank()) +
# theme(panel.grid.major.y=element_blank()) +
theme(panel.grid.major.x=element_line()) +
theme(axis.ticks=element_blank()) +
theme(panel.border=element_blank()) +
theme(legend.position="top")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SciencesPo)
Loading required package: ggplot2
initializing ... done

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SciencesPo/theme_pub.Rd_%03d_medium.png", width=480, height=480)
> ### Name: theme_pub
> ### Title: The Default Theme
> ### Aliases: theme_pub
> 
> ### ** Examples
> 
> PreviewTheme()+theme_pub()
> 
> ggplot(diamonds,aes(cut, group=1)) + geom_bar()+
+ geom_freqpoly(stat="count",size=2) + theme_pub(line_width=2.5)
> 
> ggplot(diamonds,aes(cut, group=1)) +
+ geom_bar()+
+ geom_freqpoly(stat="count",size=2) +
+ theme_pub(base_family='serif')
> 
> dat <- data.frame()
> for(i in 1:4)
+ dat <- rbind(dat, data.frame(set=i, x=anscombe[,i], y=anscombe[,i+4]))
> 
> ggplot(dat, aes(x, y)) + geom_point(size=5, color="red",
+ fill="orange", shape=21) +
+ geom_smooth(method="lm", fill=NA, fullrange=TRUE) +
+ facet_wrap(~set, ncol=2) +
+ theme_pub(base_family='serif')
> 
> 
> ggplot(dat, aes(x, y)) + geom_point(size=5, color="red",
+ fill="orange", shape=21) +
+ geom_smooth(method="lm", fill=NA, fullrange=TRUE) +
+ facet_wrap(~set, ncol=2) +
+ theme_bw() +
+ theme(plot.background=element_rect(fill="#f7f7f7")) +
+ theme(panel.background=element_rect(fill="#f7f7f7")) +
+ theme(panel.grid.minor=element_blank()) +
+ # theme(panel.grid.major.y=element_blank()) +
+ theme(panel.grid.major.x=element_line()) +
+ theme(axis.ticks=element_blank()) +
+ theme(panel.border=element_blank()) +
+ theme(legend.position="top")
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>