[R] Lattice .ps graphic is rotated in LaTeX slides
Marc Schwartz
MSchwartz at MedAnalytics.com
Fri Oct 1 18:12:38 CEST 2004
On Fri, 2004-10-01 at 10:09, Michael Friendly wrote:
> I've generated a version of the classic dotplot of the barley data with
>
> library(lattice)
> data(barley)
>
> trellis.device("postscript", color=TRUE, file="barley2x3.ps")
> old.settings <- trellis.par.get()
> trellis.par.set("background", list(col = "white"))
> lset(list(superpose.symbol=list(pch=c(19, 1, 25, 2, 15, 22, 23),
> cex=rep(1,7),col=c("blue", "red", "darkgreen", "brown",
> "orange", "turquoise", "orchid") )))
> lset(list(fontsize = list(default = 14)))
>
> n <- length(levels(barley$year))
> dotplot(variety ~ yield | site, data = barley, groups = year,
> layout = c(2, 3), aspect = .5,
> xlab = "Barley Yield (bushels/acre)",
> key = list(points = Rows(trellis.par.get("superpose.symbol"), 1:n),
> text = list(levels(barley$year)), columns = n))
> dev.off()
> lset(theme=old.settings)
>
> It looks fine with gv (though I'd like to make the bounding box
> tighter), but when I embed it in a LaTeX slide
> (landscape, using seminar package),
>
> \begin{slide}
> \includegraphics[,height=.6\textheight]{fig/barley2x3.ps}
> \end{slide}
>
> the image is rotated 90 deg CCW. I tried to adjust for this with
>
> \includegraphics[angle=-90,height=.6\textheight]{fig/barley2x3.ps}
>
> but that gives
> ! Package graphics Error: Division by 0.
>
> What am I doing wrong, or how could I do it differently so it would work?
>
> thanks
Michael,
Try the following when specifying the trellis.device:
trellis.device("postscript", color = TRUE, file = "barley2x3.eps",
onefile = FALSE, paper = "special", horizontal = FALSE,
width = 9, height = 6)
See if that works without specifying the angle in your LaTeX for
seminar:
\begin{slide}
\begin{center}
\includegraphics[height=.6\textheight]{fig/barley2x3.eps}
\end{center}
\end{slide}
Note that when including graphics in LaTeX, you should use EPS files,
which (as noted in ?postscript) require certain device settings to
create. These include:
onefile = FALSE, paper = "special", horizontal = FALSE
and the device 'width' and 'height' settings.
This will also adjust the size of the bounding box.
HTH,
Marc Schwartz
More information about the R-help
mailing list