[R] Exporting a Graph that has lines()

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Jul 3 22:54:34 CEST 2008


R_Learner wrote:
> I'm trying to export a graph (any form is good). I'm trying to export one
> that uses plot() then lines(). however, it seems that the jpeg format and
> the pdf format only takes the first line plot, and doesn't even consider the
> additional plots. My code is the following:
> 	
> output_file<-paste(filez,".pdf",sep="")
> pdf(output_file)
> plot((x_data) ~ (y_data), main = filez)
> lines (x,z,col="red")
> dev.off()
>
> The pdf only comes out with the graph of the plot, and not of the lines.
> Does anyone know how to export multiple graph items on one plot?
>
> Thanks!
>   
That shouldn't be a problem, but the above is not reproducible without 
the data.  Are you sure that you actually executed the dev.off()? 
(pasting it onto the command line is not enough).

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list