Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using Sweave and the R package nlme: when including lattice graphics, (encapsulated in the print() command), the .eps files that are generated are all in black and white. The original graphic, (which appears in R) and the saved .pdf file are in colour, but not the .eps.

When including graphics which do not use the lattice package, the .eps files are fine. I have tried including the lattice graphics in one step, e.g.:

\begin{figure}[!h]  
\begin{center}  
\setkeys{Gin}{width=0.5\textwidth}  
<<echo=FALSE,fig=TRUE,width=4,height=4>>=
print(      plot(intervals(sulf1comp.lis),layout=c(3,1,1)#,main="Parameter Estimates     &   95% CI"  
        #,sub="Sulfadoxine: Bi-Exponential nlsList Model"  
        ))  
@ 
% 
\caption{Parameter Estimates and 95\% Confidence Intervals for Individual Model Fits       \label{label sulf_fig2}}  
 %\label{fig:}  
\end{center}  
\end{figure}  

in two steps, explicitly:

<<figa,echo=FALSE,fig=TRUE,include=FALSE>>=  
 print(plot(sulf1comp.nls,pid~resid(.,type="p"),abline=0,cex.axis=0.7,  
 #,main="Plot of Residuals by Subject (Sulfadoxine: NLS Model)"  
        ))     
@ 
%    
\begin{figure}[!h]  
\begin{center}  
\includegraphics*[height=0.5\textwidth]{analysisinprogress_sw-figa.pdf}  
 \caption{Residuals by Subject ID: Sulfadoxine Bi-Exponential NLS Model \label{label       sulf_fig1}}  
 \end{center}  
\end{figure}
%  

Without using the fig=T command, e.g.:

 <<figa,echo=FALSE>>=    
 postscript("filename.eps")    
print(plot(sulf1comp.nls,pid~resid(.,type="p"),abline=0,cex.axis=0.7,    
 #,main="Plot of Residuals by Subject (Sulfadoxine: NLS Model)"    
        ))      
 dev.off()     
 @    
 %    

And various other possibilities. I'm at my wit's end trying to figure out what I'm doing wrong. Any advice would be appreciated.

share|improve this question

1 Answer 1

Black and white is the default for eps, whereas color is the default for pdf output.

I'm not sure setting

lattice.options(default.theme = standard.theme(color = TRUE))

would solve your problem, or equivalently (from the Sweave FAQ)

library(lattice)  
ltheme <- canonical.theme(color = TRUE)      ## in-built B&W theme  
ltheme$strip.background$col <- "transparent" ## change strip bg  
lattice.options(default.theme = ltheme)      ## set as default  

but do you have any particular reason to prefer Postscript over PDF? I always found that the latter produce very nice looking graphics.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.