Mercurial > hg > plosone_underreview
diff scripts_R/MetadataPlots.R @ 91:d3e05cd49feb branch-tests
trying to plot wrt PLOSONE guidelines
author | Maria Panteli <m.x.panteli@gmail.com> |
---|---|
date | Mon, 02 Oct 2017 15:32:51 +0100 |
parents | bde45ce0eeab |
children |
line wrap: on
line diff
--- a/scripts_R/MetadataPlots.R Mon Oct 02 12:37:55 2017 +0100 +++ b/scripts_R/MetadataPlots.R Mon Oct 02 15:32:51 2017 +0100 @@ -1,6 +1,13 @@ library(rworldmap) library(ggplot2) +library(extrafont) +font_import() +loadfonts() +Arial <- Type1Font(family="Arial", metrics=c("ArialMT.afm","arial-BoldMT.afm","Arial-ItalicMT.afm", "Arial-BoldItalicMT.afm")) +postscriptFonts(Arial=Arial) +par(family="Arial") + PlotBarChart<- function(df, cat="Language", ordercat="REGION", mincount=10, legend=T, color_plt="Paired"){ idx_cat = which(colnames(df)==cat) idx_ordercat = which(colnames(df)==ordercat) @@ -13,7 +20,7 @@ #g = g+ylim("0", "100")#+scale_y_discrete(breaks=c("100"),labels=c("100+")) g=g+scale_y_continuous(limits=c(0, 200), breaks=seq(0,200,40)) g=g+scale_fill_brewer(palette=color_plt) - g=g+theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.5)) + g=g+theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.5), text = element_text(size=12)) g=g+labs(y="Counts",x=cat)+coord_flip()+theme_bw() if (legend){ g=g+guides(fill = guide_legend(title = ordercat))} @@ -76,7 +83,11 @@ #do.call( addMapLegend, c(mapParams, labelFontSize=0.7, legendWidth=0.5, tcl=0.3, legendMar = 7, legendLabels="all",horizontal=T, legendIntervals="page")) legend("left", legend = c(paste(seq(90,0,-10),'-',seq(100,10,-10),'%'), 'NA'), fill = c(heat.colors(10, alpha = 1), 'grey'), cex = 0.56, bty = "o",bg="white",box.lwd=0,box.col="white") if (output!=''){ - pdf(output) + if (grepl('.pdf', output)){ + pdf(output, pointsize=12) + } else if (grepl('.eps', output)){ + postscript(output, pointsize=12) + } #mapParams <- mapCountryData(spdf, nameColumnToPlot="Outliers",catMethod=seq(0,70,5),missingCountryCol='grey',colourPalette='heat', mapTitle="", addLegend=FALSE) mapParams <- mapCountryData(spdf, nameColumnToPlot="Outliers", catMethod=seq(0,1,0.1), missingCountryCol='grey',colourPalette='heat', mapTitle="", addLegend=FALSE) #mapParams <- mapCountryData(spdf, nameColumnToPlot="Outliers", ylim=c(-60,90), catMethod=seq(0,1,0.1), missingCountryCol='grey',colourPalette='heat', mapTitle="", addLegend=FALSE)