a b/downstream_analysis/publication_plot_theme.R
1
############ run this part every time before plotting
2
library('ggplot2')
3
library('ggpubr')
4
library('ggsci')
5
library('data.table')
6
library('grid')
7
library('ggthemes')
8
theme_Publication <- function(base_size=14, base_family="helvetica") {
9
      (theme_foundation(base_size=base_size, base_family=base_family)
10
       + theme(plot.title = element_text(size = rel(1.2), hjust = 0.5),
11
               text = element_text(),
12
               panel.background = element_rect(colour = NA),
13
               plot.background = element_rect(colour = NA),
14
               panel.border = element_rect(colour = NA),
15
               axis.title = element_text(size = rel(1)),
16
               axis.title.y = element_text(angle=90,vjust =2),
17
               axis.title.x = element_text(vjust = -0.2),
18
               axis.text = element_text(), 
19
               axis.line = element_line(colour = "black"),
20
               axis.ticks = element_line(),
21
               panel.grid.major = element_line(colour="#f0f0f0"),
22
               panel.grid.minor = element_blank(),
23
               legend.key = element_rect(colour = NA),
24
               legend.position = "bottom",#bottom
25
               legend.direction = "horizontal",#horizontal
26
               legend.key.size= unit(0.2, "cm"),
27
               #legend.margin = unit(0, "cm"),
28
               legend.title = element_text(face="italic"),
29
               plot.margin=unit(c(10,5,5,5),"mm"),
30
               strip.background=element_rect(colour="#f0f0f0",fill="#f0f0f0"),
31
               strip.text = element_text()
32
          ))
33
      
34
}
35
36
scale_fill_Publication <- function(...){
37
      library(scales)
38
      discrete_scale("fill","Publication",manual_pal(values = c("#386cb0","#fdb462","#7fc97f","#ef3b2c","#662506","#a6cee3","#fb9a99","#984ea3","#ffff33","#006400")), ...)
39
40
}
41
42
scale_colour_Publication <- function(...){
43
      library(scales)
44
      discrete_scale("colour","Publication",manual_pal(values = c("#386cb0","#fdb462","#7fc97f","#ef3b2c","#662506","#a6cee3","#fb9a99","#984ea3","#ffff33","#006400")), ...)
45
46
}
47