Though R plots sent to a PDF can be rescaled at will in an illustration or page layout software, scientific journals often insist that the plots provided have specific dimension
Journals insist on having specific plot dimensions in order to avoid scaling. If made, it can render the font size too small (or large) and inconsistent with the figure caption font size. That is why the plot elements (text, point size, etc.) by design have the same absolute size regardless of pdf size.
You can change the default font size and point size, for example, with:
p <- ggplot(iris, aes(x=Petal.Width, y=Petal.Length, colour=Species)) +
geom_point(size=1.5) + # default is 2
theme_grey(base_size=10) # default is 12
ggsave("test.1.pdf", p)
The defaults can be changed globally, too:
update_geom_defaults("point", list(size=1.5))
theme_set(theme_grey(base_size=10))
An option equally good or better than pdf is tiff. All journals I have come across like tiff.
tiff(filename="name.tiff", width=5, height=5, units="in",
pointsize=8, compression="lzw", bg="white", res=600,
restoreConsole=TRUE)
qplot(data=iris, x=Petal.Width, y=Petal.Length, colour=Species)
dev.off()
If you are on linux, drop restoreConsole=TRUE
, seems only windows likes that.
Consider using width, height and pointsize in pdf() function.
If you like to stick with using pdf() instead of other ways like using sweave, then you would better use pdf function with more arguments, like bellow (I do not have ggplot2 installed, so simillar case is supplied).
# making scaled plot in pdf
# using paper=a4 just to see the efect
for (sc in c(0.5,0.75,1)) {
pdf(width=7*sc,height=7*sc,pointsize=12*sc,file=paste("scale",sc,".pdf",sep=""),paper="a4")
plot(sin((1:314)/100),main=paste("PDF sc",sc))
dev.off()
}
It is quite usable, but works in some extent. Once the scale is too small, pdf will start to enforce linewidth, fontsize etc.
See the results in scale*.pdf created by example.
And for ggplot2 ...
sc <- c(0.5,0.75,1)
fi <- c("pic1.pdf","pic2.pdf","pic3.pdf")
require(ggplot2)
p <- qplot(data=iris,
x=Petal.Width,
y=Petal.Length,
colour=Species)
for (i in 1:3) {
pdf(width=7*sc[i],height=7*sc[i],pointsize=12*sc[i],file=fi[i])
print(p)
dev.off()
}
Latex code to test the files how they look in one document:
\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphics}
\begin{document}
\begin{figure}
\includegraphics{pic1.pdf}
\end{figure}
\begin{figure}
\includegraphics{pic2.pdf}
\end{figure}
\begin{figure}
\includegraphics{pic3.pdf}
\end{figure}
\end{document}
Oddly enough, you can do this with scale=
in ggsave(...)
require(ggplot2)
p <- qplot(data=iris, x=Petal.Width, y=Petal.Length, colour=Species)
ggsave("test.1.pdf",p)
ggsave("test.2.pdf",p, width=3, height=3, units="in", scale=3)
Try playing with the scale
parameter and see what you get...