[R] Question on big JPG plots in function warpping format

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 10 17:12:58 CET 2006


Most likely this is FAQ 7.22.

althogh how we are supposed to know what plotHeatTrellis does is beyond 
me.

On Fri, 10 Feb 2006, alexfang at stat.rutgers.edu wrote:

>
>
> Hello:
>
> I have problems generating big JPG plots in functions.  the following code runs
> fine in the script:
>
> #### runs fine in script, generate 40k "test1.jpg" in the given directory
> plotPlatesAlong <- c(1:5)
> plotDirPath <- paste(dataPath, "OutputPlots\\", sep="")
> filename <-   paste(plotDirPath,"test1.jpg", sep="")
> jpeg(file=filename)
> plotHeatTrellis(dataPath, plotVariable = "Raw", plotPlatesAlong)
>    # here plotHeatTrellis() generates a complicate plot, but it works
> dev.off()
> #### End of script
>
>
> but if I wrap it in a function, it doesn't work.
>
> ######## put it in a function and run test(dataPath)
> ######## it will make "test1.jpg" in the given directory, but only 6k in size
> ######## and if I open the file, it's blank
> test <- function(dataPath) {
> plotPlatesAlong <- c(1:5)
> plotDirPath <- paste(dataPath, "OutputPlots\\", sep="")
> filename <-   paste(plotDirPath,"test1.jpg", sep="")
> jpeg(file=filename) #
> plotHeatTrellis(dataPath, plotVariable = "Raw", plotPlatesAlong)
> dev.off()
> }
> ######### enf of the program
>
>
> I've tested the simple plot function, like
>
> ########## works fine both with in script and function wrapping format
> testplot <- function(plotDirPath) {
> filename1 <- paste(plotDirPath, "test1.jpg",sep="")
> jpeg(file=filename1)
> plot(1:10, rnorm(10, 0), type="b")
> dev.off()
> }
> ###########
>
> Any one have any clues, why this happen and how could I fix my code and my mine
> working also in the function wrapping format?  Thanks.
>
>
> best, Alex
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list