symmetrise_scale <- function(p, axis = "x"){ gb <- ggplot_build(p) type <- switch(axis, "x" = "x.range", "y" = "y.range") lims <- sapply(gb$panel$ranges, "[[", type) fname <- as.character(p$facet$facets) facets <- gb$panel$layout[[fname]] lims2 <- as.vector(t(tcrossprod(apply(abs(lims), 2, max), c(-1,1)))) dummy <- setNames(data.frame(rep(facets, each=2), lims2), c(fname, axis)) switch(axis, "x" = p + geom_blank(data=dummy, aes(x=x, y=Inf)), "y" = p + geom_blank(data=dummy, aes(x=Inf, y=y))) } ft=theme(plot.title = element_text( color=1, face="bold", size=16, hjust=0.5,vjust=.9)) + theme(axis.title = element_text( color="black", face="bold", size=14))+ theme(axis.text.x = element_text( color="black", face="bold", size=12,vjust=.5))+ theme(axis.text.y = element_text( color="black", face="bold", size=12,vjust=.5)) # theme( plot.margin=unit(c(3,1,3,3),"mm")) ft1=theme(plot.title = element_text( color="black", face="bold", size=16, hjust=0.5,vjust=.9)) + theme(axis.title = element_text( color="black", face="bold", size=14))+ theme(axis.text.x = element_text( color="black", face="bold", size=12))+ theme(axis.text.y = element_text( color="black", face="bold", size=12,vjust=.5)) # element_blank() # theme(plot.margin=unit(c(3,1,3,1),"mm")) #left col in 4th place # multiplot <- function(..., plotlist=NULL, file, cols=1, widths= rep(1,cols),layout=NULL) { library(grid) # Make a list from the ... arguments and plotlist plots <- c(list(...), plotlist) numPlots = length(plots) # If layout is NULL, then use 'cols' to determine layout if (is.null(layout)) { # Make the panel # ncol: Number of columns of plots # nrow: Number of rows needed, calculated from # of cols layout <- matrix(seq(1, cols * ceiling(numPlots/cols)), ncol = cols, nrow = ceiling(numPlots/cols)) } if (numPlots==1) { print(plots[[1]]) } else { # Set up the page grid.newpage() pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout)),width=widths )) # Make each plot, in the correct location for (i in 1:numPlots) { # Get the i,j matrix positions of the regions that contain this subplot matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row, layout.pos.col = matchidx$col)) } } } library(RColorBrewer) fte_theme <- function() { # Generate the colors for the chart procedurally with RColorBrewer palette <- brewer.pal("Greys", n=9) color.background = palette[2] color.grid.major = palette[3] color.axis.text = palette[6] color.axis.title = palette[7] color.title = palette[9] # Begin construction of chart theme_bw(base_size=9) + # Set the entire chart region to a light gray color theme(panel.background=element_rect(fill=color.background, color=color.background)) + theme(plot.background=element_rect(fill=color.background, color=color.background)) + theme(panel.border=element_rect(color=color.background)) + # Format the grid theme(panel.grid.major=element_line(color=color.grid.major,size=.25)) + theme(panel.grid.minor=element_blank()) + theme(axis.ticks=element_blank()) + # Format the legend, but hide by default theme(legend.position="none") + theme(legend.background = element_rect(fill=color.background)) + theme(legend.text = element_text(size=7,color=color.axis.title)) + # Set title and axis labels, and format these and tick marks theme(plot.title=element_text(color=color.title, size=10, vjust=1.25)) + theme(axis.text.x=element_text(size=7,color=color.axis.text)) + theme(axis.text.y=element_text(size=7,color=color.axis.text)) + theme(axis.title.x=element_text(size=8,color=color.axis.title, vjust=0)) + theme(axis.title.y=element_text(size=8,color=color.axis.title, vjust=1.25)) + # Plot margins theme(plot.margin = unit(c(0.35, 0.2, 0.3, 0.35), "cm")) } #Pressure #pg=ggplot()+ # geom_line(data=fig21[fig21$variable=="P",],aes(time,diff,group=team,col=team,linewidth=2))+ # labs(x="Time (minutes)",y="Pressure (psi Master)")+ # ggtitle("Exponent Figure 21: Dry less Wet")+ ft #pg+ geom_vline(xintercept = 240, linetype="dashed", color = "red") #ggplot()+ geom_line(data=X,aes(x=time,y=tem,group=factor(paste(team,cond)),col=team,linetype=cond))+ # labs(x="Minutes after Half-Time",y="Temperature" )+ # ggtitle("Implied Temperature: Figure 27")+ ft