Anna Zakrisson Braeunlich
2013-Sep-20 10:55 UTC
[R] saving as TIFF - problem with compression
Hi, I am struggling to save my figures as TIFF files (yes, the yournal only accept TIFF and not any other format). I can manage to save a simple plot as TIFF at the correct dpi (I need at least 600dpi) and compression works. Only not for my own plot. Everything looks distorted. I have read Stack Overflow and tried to change the point size to 6, but with no apparent effect. Why is this and what would be the solution? The TIFF-stuff is in the end of the script. thank you for your time! Ndata <- data.frame( Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), sd = rep(c(1, 3, 6), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) Pdata <- data.frame( Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), sd = rep(c(0.1, 0.2, 0.4), each = 40)), fyear = rep(c('2007', '2008'), each = 100*2), Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, mean = mean(Ncellpercent), sd = sd(Ncellpercent)) names(Pdata) SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, mean = mean(Ppercentcell), sd = sd(Ppercentcell)) SummPdata library(lattice) library(latticeExtra) library(HH) font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") my.theme <- list( par.xlab.text = font.settings, par.ylab.text = font.settings, axis.text = font.settings, par.sub=font.settings) plotN <- xyplot(mean ~ Week | Station*fyear, col="black", pch=1, cex=1.1, lty=1, strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.02, y = 0.55, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Nc"), xlab="Week", data= SummNdata,type="o", par.settings = my.theme) plotP <- xyplot(mean ~ Week | Station*fyear, col="black", pch=2, cex=1.1, lty=2, strip = strip.custom(bg = 'white', style=1), key=list(text=list(c(""), col=c("black")), points=list(pch=1, lty=1, cex=1.5, col=c("black")), columns=1, border=F, x = 0.2, y = 0.2, corner = c(2, 2), title="", cex.title=1.3), ylab = ("Pc"), xlab="Week", data= SummPdata,type="o", par.settings = my.theme) tiff(file="myplot.tiff", bg="white", res=800, width=13.3, height=9.45, units="cm", pointsize="6", compression = "lzw") doubleYScale(plotN, plotP, add.ylab2 = TRUE) dev.off() this works: tiff(file="myplot8.tiff", bg="white", res=800, width=13.3, height=9.45, units="cm", pointsize="6", compression = "lzw") plot(1:100) dev.off() Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakrisson@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• `•. .><((((º>[[alternative HTML version deleted]]
Hi, Are you using Linux? If so, you may use ImageMagick and try your luck using convert filename.whatever.format filename.tiff There are lots of options in ImageMagick. (Read the manual.) I have done this in the past, and it has worked. However, your exact situation may be different, so sorry if this information is not particularly helpful. Ranjan On Fri, 20 Sep 2013 10:55:03 +0000 Anna Zakrisson Braeunlich <anna.zakrisson at su.se> wrote:> Hi, > > I am struggling to save my figures as TIFF files (yes, the yournal only accept TIFF and not any other format). > I can manage to save a simple plot as TIFF at the correct dpi (I need at least 600dpi) and compression works. Only not for my own plot. Everything looks distorted. I have read Stack Overflow and tried to change the point size to 6, but with no apparent effect. Why is this and what would be the solution? The TIFF-stuff is in the end of the script. > thank you for your time! > > Ndata <- data.frame( > Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40), > sd = rep(c(1, 3, 6), each = 40)), > fyear = rep(c('2007', '2008'), each = 100*2), > Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), > Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) > > Pdata <- data.frame( > Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40), > sd = rep(c(0.1, 0.2, 0.4), each = 40)), > fyear = rep(c('2007', '2008'), each = 100*2), > Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE), > Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE)) > > SummNdata <- ddply(Ndata, .(Week, fyear, Station), summarise, > mean = mean(Ncellpercent), > sd = sd(Ncellpercent)) > names(Pdata) > SummPdata <- ddply(Pdata, .(Week, fyear, Station), summarise, > mean = mean(Ppercentcell), > sd = sd(Ppercentcell)) > SummPdata > library(lattice) > library(latticeExtra) > library(HH) > > font.settings <- list( font = 1, cex = 1.2, fontfamily = "serif") > > my.theme <- list( > par.xlab.text = font.settings, > par.ylab.text = font.settings, > axis.text = font.settings, > par.sub=font.settings) > > plotN <- xyplot(mean ~ Week | Station*fyear, > col="black", > pch=1, > cex=1.1, > lty=1, > strip = strip.custom(bg = 'white', style=1), # why can I not use fontfamily="serif" here ??? > key=list(text=list(c(""), > col=c("black")), > points=list(pch=1, lty=1, cex=1.5, > col=c("black")), > columns=1, border=F, > x = 0.02, y = 0.55, corner = c(2, 2), > title="", cex.title=1.3), > ylab = ("Nc"), > xlab="Week", > data= SummNdata,type="o", > par.settings = my.theme) > > > plotP <- xyplot(mean ~ Week | Station*fyear, > col="black", > pch=2, > cex=1.1, > lty=2, > strip = strip.custom(bg = 'white', style=1), > key=list(text=list(c(""), > col=c("black")), > points=list(pch=1, lty=1, cex=1.5, > col=c("black")), > columns=1, border=F, > x = 0.2, y = 0.2, corner = c(2, 2), > title="", cex.title=1.3), > ylab = ("Pc"), > xlab="Week", > data= SummPdata,type="o", > par.settings = my.theme) > > tiff(file="myplot.tiff", bg="white", res=800, > width=13.3, height=9.45, units="cm", pointsize="6", > compression = "lzw") > doubleYScale(plotN, plotP, add.ylab2 = TRUE) > dev.off() > > > this works: > tiff(file="myplot8.tiff", bg="white", res=800, > width=13.3, height=9.45, units="cm", pointsize="6", > compression = "lzw") > plot(1:100) > dev.off() > > Anna Zakrisson Braeunlich > PhD student > > Department of Ecology, Environment and Plant Sciences > Stockholm University > Svante Arrheniusv. 21A > SE-106 91 Stockholm > Sweden/Sverige > > Lives in Berlin. > For paper mail: > Katzbachstr. 21 > D-10965, Berlin - Kreuzberg > Germany/Deutschland > > E-mail: anna.zakrisson at su.se > Tel work: +49-(0)3091541281 > Mobile: +49-(0)15777374888 > LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b > > ><((((_>`_. . _ `_. ._ `_. . ><((((_>`_. . _ `_. ._ `_. .><((((_>`_. . _ `_. ._ `_. .><((((_> > > [[alternative HTML version deleted]] >-- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses. ____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!