Skip to content
Back to formatted view

Raw Message

Message-ID: <1139586070.43ecb4167c833@outlier.rutgers.edu>
Date: 2006-02-10T15:41:10Z
From: Alex
Subject: Question on big JPG plots in function warpping format

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