On Jul 19, 2011, at 5:40 AM, creamers wrote:

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.

You have obviously advance far in you understanding of the underpinnings of lattice plots, farther than I in many respects. I was surprised, therefore, to see that you were directly accessing elements of your data in the global environment. Generally lattice functions work best when they are given data.frames as arguments.

The other (more specific to your problem) comment is that replacement strip functions are generally constructed with the function strip.custom(). I get the impression for the docs that this may be required, but apparently you succeeded with single plot testing and it may be a device issue, so I may be off base. You could still take a look at the examples in the help page and see if using that wrapper gets you better delivery of arguments to the operative code.

Obviously not able to do any testing, since you have not constructed a minimal test dataframe. Device issues often require knowing OS and other information that the Posting Guide requests you provide with sessionInfo().

--
David.

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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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