ggplot2 0.9.2 のテーマを作成
ggplot2は、バージョン0.9.2からテーマ関連が大幅に変更された。それに合わせて、以前公開したggplot2 のテーマを作成 - joker8phoenixの日記 も以下の内容に更新。
library(ggplot2) library(reshape) library(scales) library(grid) ############# ### theme ### ############# mytheme <- function ( base_size=18, margin.top=1, margin.side=0.5, base_family="Helvetica", number_family="Helvetica", ls=0, strip.ls=0, border="grey50", legend="right", major=NA,#"grey50", minor=NA#"grey90" ) { vjust=0.4 hjust=0.5 angle=90 if(ls==1){ vjust=1.02 hjust=6 angle=0 } s.angle=-90 if(strip.ls==1){ s.angle=0 } theme( axis.line=element_line(colour="black"), axis.text.x=element_text(family=number_family, size=base_size*0.8, lineheight=0.9, colour="black", vjust=1), axis.text.y=element_text(family=number_family, size=base_size*0.8, lineheight=0.9, colour="black", hjust=1), axis.ticks=element_line(colour="black", size=0.2), axis.title.x=element_text(family=base_family, size=base_size, vjust=0.0, hjust=0.5), axis.title.y=element_text(family=base_family, size=base_size, vjust=vjust, hjust=hjust, angle=angle), axis.ticks.length=unit(0.3, "cm"), axis.ticks.margin=unit(0.1, "cm"), legend.background=element_rect(colour=NA), legend.margin=unit(0.2, "cm"), legend.key=element_rect(fill=NA, colour=NA), legend.key.size=unit(1.2, "lines"), legend.key.height = NULL, legend.key.width = NULL, legend.text=element_text(family=base_family, size=base_size*0.8,face="bold",hjust=0), legend.text.align = NULL, legend.title=element_text(family=base_family, size=base_size*0.8,face="bold", hjust=0), legend.title.align = NULL, legend.position=legend, legend.direction = NULL, legend.justification = "center", legend.box = NULL, panel.background=element_blank(), panel.border=element_rect(fill=NA, colour=border), panel.grid.major=element_line(colour=major, size=0.2), panel.grid.minor=element_line(colour=minor, size=0.5), panel.margin=unit(0.25, "lines"), strip.background=element_rect(fill="grey80",colour="black"), strip.text.x=element_text(family=base_family,face="plain",colour="black",size=base_size*0.8,hjust=0.5,vjust=0.5,angle=0,lineheight=0), strip.text.y=element_text(family=base_family,face="plain",colour="black",size=base_size*0.8,hjust=0.5,vjust=0.5,angle=s.angle,lineheight=0), plot.background=element_blank(), plot.title=element_text(family=base_family, size=base_size, face="plain", vjust=1), plot.margin=unit(c(margin.top, margin.side, margin.top, margin.side), "lines"), complete=T) }