[R] Publication-ready figures in R?
arun
smartpink111 at yahoo.com
Tue Jan 28 18:05:56 CET 2014
Hi,
May be this helps you in getting started:
library(lattice)
library(grid)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
main= "Some plot",
groups = rowpos, type = "a",
scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
page = function(n){
grid.text(LETTERS[j],
y = 0.95,
x = 0.15,
default.units = "npc",
just = c("left"),
gp = gpar(fontsize = 12,fontface="bold") )
},
par.settings = c(simpleTheme(lty=1:8, col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights = list(main = 1.2,
sub = 0,
axis.top = 0.2,
top.padding = 0.1,
bottom.padding = 0,
axis.bottom=0.8)) ),
auto.key = list(x = 0.2, y = 0.9,
cex = 0.75, points = FALSE, lines = TRUE))
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.45), more = FALSE)
grid.text("Upper row", x=0.5, y=0.97, gp=gpar(fontsize=12, col="black"))
grid.text("Lower row", x=0.5, y=0.47, gp=gpar(fontsize=12, col="black"))
A.K.
On Tuesday, January 28, 2014 10:45 AM, "Bebber, Dan" <D.Bebber at exeter.ac.uk> wrote:
I would like to make a plea for "publication-ready" figures from R.
The default figures produced by R (both traditional and lattice graphics) need to be amended (by users) in many respects to be acceptable by publishers.
I imagine that most R users are producing figures for publication, and it seems inefficient that so many adjustments need to be made.
Although publishers vary in their requirements, there is a general request for minimal whitespace, and labelling of figure parts with a, b, c etc. in the top left corner that should be easy to achieve in R.
For traditional graphics the main issues relate to white space, which could be reduced by e.g. par(mar =c(3,3,1,1), mgp = c(2,0.5,0), las = 1, tcl = -0.25) as defaults
Labelling parts inside the plot region can be achieved by e.g. legend("topleft", legend = "A", bty = "n", x.intersp = 0, y.intersp = 0).
Labelling parts outside the plot region can almost be achieved by e.g. mtext("A", side = 3, adj = 0), although the label is too far to the right, rather than being in the top left corner.
For lattice graphics, whitespace can be reduced by adjusting trellis parameters as has been discussed previously, e.g.
https://stat.ethz.ch/pipermail/r-help/2007-January/123556.html
However, labelling panels in lattice with a,b,c etc. in the top left corner seems extremely difficult and involved, as has been discussed previously e.g.
http://r.789695.n4.nabble.com/Adding-text-labels-to-lattice-plots-with-multiple-panels-td3436700.html
Although the lattice strips are very useful for identifying panels, publishers (in my field, at least) never allow this kind of labelling.
Therefore my question is: Could the default plotting functions be amended to make it easier for users to produce publication-ready graphics?
Dan Bebber
Department of Biosciences
University of Exeter
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list