Hi.....I am relatively new to R but was quite pleased with myself at having
generated a series of lattice plots as PDFs. I was very surprised when
plotting these out as jpegs (or png or tiff) that the strip title
information above each lattice plot vanished. The pdf was fine. Has anybody
any ideas? I can't add an image as the information is sensitive.

Many Thanks
Steve Creamer

Here is the code snippet 

#jpeg("Z:\\My Documents\\PROJECTS\\Access
Policy\\AccessDAPlots_1.jpg",height=600,width=600)
pdf("Z:\\My Documents\\PROJECTS\\Access Policy\\AccessDAPlots_1.pdf")
#png("Z:\\My Documents\\PROJECTS\\Access Policy\\AccessDAPlots_1.png")
#tiff("Z:\\My Documents\\PROJECTS\\Access Policy\\AccessDAPlots_1.tiff")
while (irec <= nrec)
{
   con_new<-consultants[irec]
   spec_new<-specialty[irec]
   spec_cons_new<-spec_cons[irec]

   if (spec_cons_new!=spec_cons_old || irec==nrec )
   {
      strip_name[con_count]<-paste(spec_old,'\n',con_old)
      if (spec_new!=spec_old || irec==nrec)
      {
      spec_old<-spec_new
   }
      con_count<-con_count+1
      if (con_count > 36 || irec==nrec )
      {

#       
-------------------------------------------------------------------------------------------------
#        Use xyplot for the lattice - plot from iStartRec to irec each times
- this will be 36 consultants
#        /specialties per device plot.
#       
-------------------------------------------------------------------------------------------------

        
tplot<-xyplot(DAtotals[irecStart:(irec-1)]~dates[irecStart:(irec-1)]
                      
|spec_cons[irecStart:(irec-1)],group=nf[irecStart:(irec-1)],layout=c(6,6),
                       type='b',as.table=TRUE,
                       main=paste("Monthly Appts Provided After 1 DNA\n by
Specialties/Consultants - ",iSuffix),
                       auto.key = list(cex=0.5,lines=TRUE,
points=FALSE,border = TRUE, x=0.05,y=0.90,corner=c(0,0)),
                       ylab = "Number of Monthly Attended Appts Following a
DNA ",xlab="Date",
                       scales = list(x = list(rot = 90,format="%b-%y",
                       cex=0.6)),xaxt="n",
                       strip = function(which.panel,...) 
                             {
                               
panel.fill(trellis.par.get("strip.background")$col[1])
                                type <- strip_name[which.panel]
                                grid::grid.text(label = type,x = 0.5, y =
0.5,gp=grid::gpar(fontsize=5))
                                grid::grid.rect() 
                             }
                       )
         print(tplot) # plot the lattice plot
         con_count<-1
         irecStart<-irec
         iSuffix<-iSuffix+1 # create suffix 
         if (irec != nrec)
         {

#           ------------------------------------------------
#           Open new device and direct to jpeg with new name
#           ------------------------------------------------
            dev.off()
            graphics.off() # turn graphics off to clear memory
            dev.new()

#            jpeg(paste("Z:\\My 
Documents\\PROJECTS\\AccessPolicy\\AccessDAPlots_",toString(iSuffix),".jpg",sep=""),
#                  height=600,width=600)
            pdf(paste("Z:\\My Documents\\PROJECTS\\Access
Policy\\AccessDAPlots_",toString(iSuffix),".pdf",sep=""))
#            png(paste("Z:\\My Documents\\PROJECTS\\Access
Policy\\AccessDAPlots_",toString(iSuffix),".png",sep=""))
#            tiff(paste("Z:\\My Documents\\PROJECTS\\Access
Policy\\AccessDAPlots_",toString(iSuffix),".tiff",sep=""))
         }
      }
      con_old<-con_new
      spec_cons_old<-spec_cons_new
   }  
   irec<-irec+1
}


--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-plot-problem-outputting-to-jpeg-tp3677705p3677705.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to