Last active
February 22, 2017 21:00
-
-
Save xupefei/aba97e9ab9fc9d8954fb8ad19079d7f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
theme_Publication <- function(base_size = 16) { | |
library(grid) | |
library(ggthemes) | |
( | |
theme_foundation(base_size = base_size) | |
+ theme( | |
plot.title = element_text( | |
face = "bold", | |
size = rel(1.2), | |
hjust = 0.5 | |
), | |
text = element_text(), | |
panel.background = element_rect(colour = NA), | |
plot.background = element_rect(colour = NA), | |
panel.border = element_rect( | |
fill = NA, | |
colour = "black", | |
size = rel(1.25) | |
), | |
axis.title = element_text(face = "bold", size = rel(1)), | |
axis.title.y = element_text(angle = 90, vjust = -2), | |
axis.title.x = element_text(vjust = 10), | |
axis.text = element_text(), | |
axis.line = element_line(colour = "black", size = rel(0.75)), | |
axis.ticks = element_line(size = rel(0.75)), | |
axis.ticks.length = unit(-0.25, "cm"), | |
axis.text.x = element_text(margin = unit(c(0.5, 0.5, 0.5, 0.5), "cm")), | |
axis.text.y = element_text(margin = unit(c(0.5, 0.5, 0.5, 0.5), "cm")), | |
panel.grid.major = element_line(colour = "#f0f0f0", size = rel(0.75)), | |
panel.grid.minor = element_blank(), | |
legend.key = element_rect(colour = NA), | |
legend.position = "bottom", | |
legend.direction = "horizontal", | |
legend.key.size = unit(0.2, "cm"), | |
legend.margin = margin(1, 1, 1, 0, "mm"), | |
legend.background = element_rect(colour = "black", size = rel(0.5)), | |
#legend.title = element_text(face = "italic"), | |
plot.margin = unit(c(2, 2, 1, 1), "mm"), | |
strip.background = element_rect(colour = "#f0f0f0", fill = "#f0f0f0"), | |
strip.text = element_text(face = "bold") | |
) | |
) | |
} | |
scale_fill_Publication <- function(...) { | |
library(scales) | |
discrete_scale("fill", "Publication", manual_pal( | |
values = c( | |
"#386cb0", | |
"#fdb462", | |
"#7fc97f", | |
"#ef3b2c", | |
"#662506", | |
"#a6cee3", | |
"#fb9a99", | |
"#984ea3", | |
"#ffff33" | |
) | |
), ...) | |
} | |
scale_colour_Publication <- function(...) { | |
library(scales) | |
discrete_scale("colour", "Publication", manual_pal( | |
values = c( | |
"#386cb0", | |
"#fdb462", | |
"#7fc97f", | |
"#ef3b2c", | |
"#662506", | |
"#a6cee3", | |
"#fb9a99", | |
"#984ea3", | |
"#ffff33" | |
) | |
), ...) | |
} | |
legend_title <- function(tit = "Legend") { | |
guides(colour = guide_legend(title = tit), shape = guide_legend(title = tit)) | |
} | |
legend_pos <- function(pos = "rt") { | |
if (pos == "lt") { | |
theme(legend.justification = c(0, 1), | |
legend.position = c(0.01, 0.99)) | |
} | |
else if (pos == "rt") { | |
theme(legend.justification = c(1, 1), | |
legend.position = c(0.99, 0.99)) | |
} | |
else if (pos == "lb") { | |
theme(legend.justification = c(0, 0), | |
legend.position = c(0.01, 0.01)) | |
} | |
else if (pos == "rb") { | |
theme(legend.justification = c(1, 0), | |
legend.position = c(0.99, 0.01)) | |
} | |
else{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment