Skip to content

Commit

Permalink
nov
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinanddavis authored Nov 29, 2018
1 parent 2dcc91d commit e2263e9
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions snail_mesocosm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -196,46 +196,22 @@ cex_diam <- meso1$Diameter/3

### Set plotting graphics
```{r, cache = TRUE, tidy = TRUE, lazy = TRUE, results="hide"}
plot_it <- function(manuscript,bg,cp,alpha,family){ # plotting function (plot for MS or not, set bg color, set color palette from RColorBrewer, set alpha value for transperancy)
graphics.off()
if(manuscript==0){
if(bg=="black"){
colvec<-magma(200,1)
par(bg = colvec[1],col.axis="white",col.lab="white",col.main="white",fg="white",bty="n",las=1,mar=c(5,6,4,2),family=family) #mono
border=adjustcolor("purple",alpha=0.5)
}else{
colvec<-bpy.colors(200)
par(bg = colvec[1],col.axis="white",col.lab="white",col.main="white",fg="white",bty="n",las=1,mar=c(5,6,4,2),family=family)
border=adjustcolor("blue",alpha=0.5)
}
}else{
# graphics.off()
par(bty="n",las=1,family=family)
}
# color palettes
# ifelse(manuscript==1,colvec<-adjustcolor(brewer.pal(9,cp)[9], alpha = alpha),colvec <- adjustcolor(brewer.pal(9,cp)[5], alpha = alpha)) # fine tune plotting colors for plotting bg
# colfunc <<- colorRampPalette(brewer.pal(9,cp),alpha=alpha)
colfunc <<- adjustcolor(brewer.pal(9,cp),alpha=alpha) # USES <<- OPERATOR
}
require(RCurl)
script <- getURL("https://raw.githubusercontent.com/darwinanddavis/plot_it/master/plot_it.R", ssl.verifypeer = FALSE)
eval(parse(text = script))
# Setting ggplot theme graphics
plot_it_gg <- function(bg){ # bg = colour to plot bg, family = font family
if(bg=="white"){
bg <- "white"
fg <- "black"
theme_tufte(base_family = "HersheySans") +
theme(panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_rect(fill = bg,colour = bg),plot.background = element_rect(fill=bg)) +
theme(axis.line = element_line(color = fg)) +theme(axis.ticks = element_line(color = fg)) + theme(plot.title = element_text(colour = fg)) +theme(axis.title.x = element_text(colour = fg), axis.title.y = element_text(colour = fg)) + theme(axis.text.x = element_text(color = fg),axis.text.y = element_text(color = fg)) + theme(legend.key = element_rect(fill = bg)) + theme(legend.title = element_text(colour=fg)) + theme(legend.text = element_text(colour=fg))
}
}# end gg
```

Set plotting parameters

```{r, cache = TRUE, tidy = TRUE, lazy=TRUE, results="hide"}
print("1/0, set colour, set colour palette 'display.brewer.all()',set alpha for col,set font")
plot_it(0,"blue","YlOrRd",1,"HersheySans") # set col function params
plot_it_gg("white") # same as above
require(RColorBrewer)
display.brewer.all()
# Set global plotting parameters
cat("plot_it( \n0 for presentation, 1 for manuscript, \nset colour for background, \nset colour palette 1. use 'display.brewer.all()', \nset colour palette 2. use 'display.brewer.all()', \nset alpha for colour transperancy, \nset font style \n)")
plot_it(0,"blue","Spectral","Greens",1,"mono") # set plot function params
plot_it_gg("white") # same as above for ggplot
# set colors you want
col <- "lightblue"
Expand Down

0 comments on commit e2263e9

Please sign in to comment.