Re: [R] Basic: setting resolution and size of an R graphic
Le 25.10.2005 14:59, Marc Schwartz a écrit : >If you specifically need the plot to have a dimension measured in >pixels, then you need to use a bitmapped format such as png and specify >the output to be the size you require: > > png("test.png", width = 300, height = 300, ...) > DoYourPlotHere() > dev.off() > >Do this directly using the png() device, rather than trying to convert >the image format, which almost always introduces "noise". > >Since you are using a bitmapped format, you will experience the tradeoff >with respect to the image quality (ie. pixelated) as compared to a >vector based format such as PDF or PS. > >I would re-verify the requirements for the journal to which you are >submitting the article relative to what they need for image specs. It >seems unusual for a journal to request an image in this fashion, unless >it is a photograph where a jpg format may be preferred or perhaps for >online publication on a web page. > >HTH, > >Marc Schwartz > > Hi folks, I just would like to highlight the argument 'pointsize' of the png function. For graphics in RGG i use pointsize=4 and i'm happy with it. Romain >On Tue, 2005-10-25 at 08:57 +0200, Dr. med. Peter Robinson wrote: > > >>Thanks Marc and Jim for the tips. The PDF file that I create with R looks >>about the same as the one you created. However, I need to get the graphic >>to be a certain size (300 pixels wide). I have been using the ImageMagick >>program to do so for other graphics: >> >>convert test.pdf -resize 300x300 out.pdf >> >>then out.pdf looks rather poor (pixelly). The original image is too big. >>ANy ideas? >>Thanks a lot,Peter >> >> >>Am Mo, 24.10.2005, 22:53, schrieb Marc Schwartz (via MN): >> >> >>>On Mon, 2005-10-24 at 22:32 +0200, Dr. med. Peter Robinson wrote: >>> >>> >>> Dear List, I am sorry if this perhaps a too basic question, but I have not found an answer in Google or in the R help system. I am trying to use R to do a very simple analysis of some data (RT-PCR and Western analysis) with a T-test and to plot the results as a histogram with error bars. (I have pasted an example script at the bottom of this mail). In order to use this for publication, I would like to adjust the resolution and size of the final image. However, even using file types such as postscript or pdf that are vector based, I get rather bad-looking results with >pdf(file="test.pdf") source("script at bottom of mail") dev.off() > > using either pdf or postscript or jpg devices. Therefore I would like to ask the list, how to best produce a graphic from the script below that would fit into one column of a published article and have a high resolution (as eps, or failing that tiff or png)? Thanks in advance for any advice, Peter >>> >>> >>> >>>What OS are you on? >>> >>> >>>Running your example on FC4, I get the attached output for a pdf(). >>> >>> >>>I suspect that on your OS, the height and width arguments are not >>>appropriate by default. >>> >>>Thus, you may need to adjust your pdf (or postscript) function call to >>>explicitly specify larger height and width arguments. >>> >>>Also note that to generate an EPS file, pay attention to the details >>>section of ?postscript, taking note of the 'onefile', 'horizontal' and >>>'paper' arguments and settings. >>> >>> >>>Also, check with your journal to see if they specify dimensions for such >>>graphics so that you can abide by their specs if provided. If they are >>>using LaTeX, there are means of specifying and/or adjusting the height >>>and/or width specs in the code based upon proportions of various measures >>>(ie. \includegraphics[width=0.9\textwidth]{GraphicsFile.eps} ). >>> >>> >>>HTH, >>> >>> >>>Marc Schwartz >>> >>> -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques +---+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---+ __ R-help@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
Re: [R] Basic: setting resolution and size of an R graphic
If you specifically need the plot to have a dimension measured in pixels, then you need to use a bitmapped format such as png and specify the output to be the size you require: png("test.png", width = 300, height = 300, ...) DoYourPlotHere() dev.off() Do this directly using the png() device, rather than trying to convert the image format, which almost always introduces "noise". Since you are using a bitmapped format, you will experience the tradeoff with respect to the image quality (ie. pixelated) as compared to a vector based format such as PDF or PS. I would re-verify the requirements for the journal to which you are submitting the article relative to what they need for image specs. It seems unusual for a journal to request an image in this fashion, unless it is a photograph where a jpg format may be preferred or perhaps for online publication on a web page. HTH, Marc Schwartz On Tue, 2005-10-25 at 08:57 +0200, Dr. med. Peter Robinson wrote: > Thanks Marc and Jim for the tips. The PDF file that I create with R looks > about the same as the one you created. However, I need to get the graphic > to be a certain size (300 pixels wide). I have been using the ImageMagick > program to do so for other graphics: > > convert test.pdf -resize 300x300 out.pdf > > then out.pdf looks rather poor (pixelly). The original image is too big. > ANy ideas? > Thanks a lot,Peter > > > Am Mo, 24.10.2005, 22:53, schrieb Marc Schwartz (via MN): > > On Mon, 2005-10-24 at 22:32 +0200, Dr. med. Peter Robinson wrote: > > > >> Dear List, > >> > >> > >> I am sorry if this perhaps a too basic question, but I have not found > >> an answer in Google or in the R help system. I am trying to use R to do > >> a very simple analysis of some data (RT-PCR and Western analysis) with a > >> T-test and > >> to plot the results as a histogram with error bars. (I have pasted an > >> example script at the bottom of this mail). In order to use this for > >> publication, I would like to adjust the resolution and size of the final > >> image. However, even using file types such as postscript or pdf that are > >> vector based, I get rather bad-looking results with > >>> pdf(file="test.pdf") source("script at bottom of mail") dev.off() > >> > >> using either pdf or postscript or jpg devices. > >> > >> > >> Therefore I would like to ask the list, how to best produce a graphic > >> from the script below that would fit into one column of a published > >> article and have a high resolution (as eps, or failing that tiff or > >> png)? Thanks in advance for any advice, > >> > >> > >> Peter > >> > > > > > > > > > > What OS are you on? > > > > > > Running your example on FC4, I get the attached output for a pdf(). > > > > > > I suspect that on your OS, the height and width arguments are not > > appropriate by default. > > > > Thus, you may need to adjust your pdf (or postscript) function call to > > explicitly specify larger height and width arguments. > > > > Also note that to generate an EPS file, pay attention to the details > > section of ?postscript, taking note of the 'onefile', 'horizontal' and > > 'paper' arguments and settings. > > > > > > Also, check with your journal to see if they specify dimensions for such > > graphics so that you can abide by their specs if provided. If they are > > using LaTeX, there are means of specifying and/or adjusting the height > > and/or width specs in the code based upon proportions of various measures > > (ie. \includegraphics[width=0.9\textwidth]{GraphicsFile.eps} ). > > > > > > HTH, > > > > > > Marc Schwartz > > > > > > > __ R-help@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
Re: [R] Basic: setting resolution and size of an R graphic
Thanks Marc and Jim for the tips. The PDF file that I create with R looks about the same as the one you created. However, I need to get the graphic to be a certain size (300 pixels wide). I have been using the ImageMagick program to do so for other graphics: convert test.pdf -resize 300x300 out.pdf then out.pdf looks rather poor (pixelly). The original image is too big. ANy ideas? Thanks a lot,Peter Am Mo, 24.10.2005, 22:53, schrieb Marc Schwartz (via MN): > On Mon, 2005-10-24 at 22:32 +0200, Dr. med. Peter Robinson wrote: > >> Dear List, >> >> >> I am sorry if this perhaps a too basic question, but I have not found >> an answer in Google or in the R help system. I am trying to use R to do >> a very simple analysis of some data (RT-PCR and Western analysis) with a >> T-test and >> to plot the results as a histogram with error bars. (I have pasted an >> example script at the bottom of this mail). In order to use this for >> publication, I would like to adjust the resolution and size of the final >> image. However, even using file types such as postscript or pdf that are >> vector based, I get rather bad-looking results with >>> pdf(file="test.pdf") source("script at bottom of mail") dev.off() >> >> using either pdf or postscript or jpg devices. >> >> >> Therefore I would like to ask the list, how to best produce a graphic >> from the script below that would fit into one column of a published >> article and have a high resolution (as eps, or failing that tiff or >> png)? Thanks in advance for any advice, >> >> >> Peter >> > > > > > What OS are you on? > > > Running your example on FC4, I get the attached output for a pdf(). > > > I suspect that on your OS, the height and width arguments are not > appropriate by default. > > Thus, you may need to adjust your pdf (or postscript) function call to > explicitly specify larger height and width arguments. > > Also note that to generate an EPS file, pay attention to the details > section of ?postscript, taking note of the 'onefile', 'horizontal' and > 'paper' arguments and settings. > > > Also, check with your journal to see if they specify dimensions for such > graphics so that you can abide by their specs if provided. If they are > using LaTeX, there are means of specifying and/or adjusting the height > and/or width specs in the code based upon proportions of various measures > (ie. \includegraphics[width=0.9\textwidth]{GraphicsFile.eps} ). > > > HTH, > > > Marc Schwartz > > > __ R-help@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
Re: [R] Basic: setting resolution and size of an R graphic
On Mon, 2005-10-24 at 22:32 +0200, Dr. med. Peter Robinson wrote: > Dear List, > > I am sorry if this perhaps a too basic question, but I have not found an > answer in Google or in the R help system. I am trying to use R to do a > very simple analysis of some data (RT-PCR and Western analysis) with a > T-test and > to plot the results as a histogram with error bars. (I have pasted an > example script at the bottom of this mail). > In order to use this for publication, I would like to adjust the > resolution and size of the final image. However, even using file types > such as postscript or pdf that are vector based, I get rather bad-looking > results with > >pdf(file="test.pdf") > >source("script at bottom of mail") > >dev.off() > > using either pdf or postscript or jpg devices. > > > Therefore I would like to ask the list, how to best produce a graphic from > the script below that would fit into one column of a published article and > have a high resolution (as eps, or failing that tiff or png)? > Thanks in advance for any advice, > > Peter What OS are you on? Running your example on FC4, I get the attached output for a pdf(). I suspect that on your OS, the height and width arguments are not appropriate by default. Thus, you may need to adjust your pdf (or postscript) function call to explicitly specify larger height and width arguments. Also note that to generate an EPS file, pay attention to the details section of ?postscript, taking note of the 'onefile', 'horizontal' and 'paper' arguments and settings. Also, check with your journal to see if they specify dimensions for such graphics so that you can abide by their specs if provided. If they are using LaTeX, there are means of specifying and/or adjusting the height and/or width specs in the code based upon proportions of various measures (ie. \includegraphics[width=0.9\textwidth]{GraphicsFile.eps} ). HTH, Marc Schwartz test.pdf Description: Adobe PDF document __ R-help@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
[R] Basic: setting resolution and size of an R graphic
Dear List, I am sorry if this perhaps a too basic question, but I have not found an answer in Google or in the R help system. I am trying to use R to do a very simple analysis of some data (RT-PCR and Western analysis) with a T-test and to plot the results as a histogram with error bars. (I have pasted an example script at the bottom of this mail). In order to use this for publication, I would like to adjust the resolution and size of the final image. However, even using file types such as postscript or pdf that are vector based, I get rather bad-looking results with >pdf(file="test.pdf") >source("script at bottom of mail") >dev.off() using either pdf or postscript or jpg devices. Therefore I would like to ask the list, how to best produce a graphic from the script below that would fit into one column of a published article and have a high resolution (as eps, or failing that tiff or png)? Thanks in advance for any advice, Peter ## Western.R ## A script to display the results of quantitative Western blotting with 6 repeats each at three dosages. ## This particular script has data from stimulation of fibroblasts with M-wt. # -- CONVENIENCE FUNCTIONS - # ## Define a simple function to draw the error bars. makeBars <- function(x,mean,se){ segments(x,mean - se/2,x,mean+se/2) segments(x-0.1,mean - se/2,x+0.1,mean - se/2) segments(x-0.1,mean + se/2,x+0.1,mean + se/2) } ##Define a simple function to write p values writeP <- function(x,mean,se,pval) { if (pval >= 0.01) { # text(x, mean + se/2 + 0.25, sprintf('p=%.2f',pval),cex=1.5) text(x +0.05, mean + se/2 + 0.4, sprintf('*'),cex=1) } else { text(x +0.05, mean + se/2 + 0.4, sprintf('**'),cex=1) } } ## define function to draw entire group ## A,B,C refer to the x positions of the x,y,z observations drawBarsAndPValueForGroup <- function(A,B,C,x.mean,x.se,y.mean,y.se,z.mean,z.se,xy.pval,xz.pval) { makeBars(A,x.mean,x.se) makeBars(B,y.mean,y.se) makeBars(C,z.mean,z.se) writeP(B - 0.05, y.mean,y.se,xy.pval) writeP(C -0.05,z.mean,z.se,xz.pval) } ## We will make a two part graphic par(mfrow=c(1,2)) ## X: 0 ## y: 0.2 µM ## z: 0.4 µM yTop <- 12 ## Limit for Y axis ## --- RT-PCR MMP1 --- ## x <- c(0.8839034,0.42011158,0.65318013 , 0.88494528,1.900606, 1.2572536 ) x.mean <- mean(x) x.se <- sd(x) / sqrt(length(x)) y <- c(5.067579666,2.630677502,1.881902881,1.61994864,3.356066695 ) y.mean <- mean(y) y.se <- sd(y)/ sqrt(length(y)) z <- c(13.38923048,3.677270765,3.559984278,10.83628903,12.20110874,12.8957108) z.mean <- mean(z) z.se <- sd(z)/ sqrt(length(z)) ## -- Do t test and calculate the p values -- ## xy.t <- t.test(y,x, alternative=c("greater"),var.equal=TRUE) xy.pval <- xy.t$p.value xz.t <- t.test(z, x, alternative=c("greater"),var.equal=TRUE) xz.pval <- xz.t$p.value arr <- c(x.mean,y.mean,z.mean) mat <- matrix(arr,nrow=3,byrow=F) barplot(mat, ## The data beside=TRUE, ## juxtapose values in each column rather than stacking them ylim=c(0,yTop), ## limits for y axis xlim=c(0,3), width=1, space=c(0,0.1),##space: the amount of space (as a fraction of the average bar width) ## left before each bar. beside=TRUE, can be given ## by 2 numbers, the space between bars within a group ## and space betweens bars of different groups names=c('0.0 µM','0.2 µM','0.4 µM'), ylab='Relative Change', col=c('white'), cex.names=1, cex.axis=1,##cex.axis: expansion factor for numeric axis labels. cex.lab=1) ## First for the RT-PCR group start <- 0.1 first <- start + 0.5 second <- start + 1.5 third <- start + 2.5 drawBarsAndPValueForGroup(first,second,third,x.mean,x.se,y.mean,y.se,z.mean,z.se,xy.pval,xz.pval) ## --- Western MMP1 --- ## x2 <- c(1.117373856,0.690266558,1.192359586 ) y2 <- c(3.53806369,3.895634049,6.653024511 ) z2 <- c(8.609814741,3.858564979,8.492977115) x2.mean <- mean(x2) x2.se <- sd(x2) / sqrt(length(x2)) y2.mean <- mean(y2) y2.se <- sd(y2)/ sqrt(length(y2)) z2.mean <- mean(z2) z2.se <- sd(z2)/ sqrt(length(2)) ## -- Do t test and calculate the p values -- ## xy2.t <- t.test(y2,x2, alternative=c("greater"),var.equal=TRUE) xy2.pval <- xy2.t$p.value xz2.t <- t.test(z2,x2,alternative=c("greater"),var.equal=TRUE) xz2.pval <- xz2.t$p.value arr <- c(x2.mean, y2.mean,z2.mean) mat <- matrix(arr,nrow=3,byrow=F) ## mat now has the values of each type of experiment in individual columns barplot(mat, ## The date beside=TRUE, ## juxtapose values in each column rather than stacking them ylim=c(0,yTop), ## limits for y axis xlim=c(0,4), width=1, space=c(0,0.1),##space: the amount of space (as a fraction of the average bar width)