Re: [R] PNG resolution
__ 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.
Re: [R] PNG resolution
Hi, For those who are interested in the solution to this problem, I modified the cairoDevice driver (version 2.10) so that it is now resolution-aware. The owner of the package will probably include my changes in his next release, but if in the meantime you would like to use the modified version, please email me. Cheers, Matthew Walker Joshua Wiley wrote: Hello Matthew, I do not have a direct answer to your problem, but you could try saving it as an EPS and then rasterizing it using a graphics program (e.g., GIMP) to whatever resolution you wanted. Best luck finding a real solution. Joshua On Tue, Jan 26, 2010 at 9:05 AM, Matthew Walker matthew.walke...@ulaval.ca mailto:matthew.walke...@ulaval.ca wrote: Hi, I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. However, when I use the res parameter of png() this is not what I see. Would someone show me how I can just increase the resolution without changing the physical sizes of elements in my plot? Maybe an example would help? Below are three images. I expect that if I print them out, let's say scaled to fit the page, then items such as the words Title Text would appear the same size. Instead (for the last two) it appears that the same number of pixels are being used, thus the text size appears smaller. What should I do to just increase the resolution? png(72dpi.png, width=6+2/3, height=6+2/3, units=in, res=72) plot(0,0, main=Title Text) dev.off() png(300dpi.png, width=6+2/3, height=6+2/3, units=in, res=300) plot(0,0, main=Title Text) dev.off() png(600dpi.png, width=6+2/3, height=6+2/3, units=in, res=600) plot(0,0, main=Title Text) dev.off() Thanks in advance, Matthew Walker __ R-help@r-project.org mailto: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 http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.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.
Re: [R] PNG resolution
Hello Matthew, I do not have a direct answer to your problem, but you could try saving it as an EPS and then rasterizing it using a graphics program (e.g., GIMP) to whatever resolution you wanted. Best luck finding a real solution. Joshua On Tue, Jan 26, 2010 at 9:05 AM, Matthew Walker matthew.walke...@ulaval.cawrote: Hi, I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. However, when I use the res parameter of png() this is not what I see. Would someone show me how I can just increase the resolution without changing the physical sizes of elements in my plot? Maybe an example would help? Below are three images. I expect that if I print them out, let's say scaled to fit the page, then items such as the words Title Text would appear the same size. Instead (for the last two) it appears that the same number of pixels are being used, thus the text size appears smaller. What should I do to just increase the resolution? png(72dpi.png, width=6+2/3, height=6+2/3, units=in, res=72) plot(0,0, main=Title Text) dev.off() png(300dpi.png, width=6+2/3, height=6+2/3, units=in, res=300) plot(0,0, main=Title Text) dev.off() png(600dpi.png, width=6+2/3, height=6+2/3, units=in, res=600) plot(0,0, main=Title Text) dev.off() Thanks in advance, Matthew Walker __ 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/ [[alternative HTML version deleted]] __ 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.
[R] PNG resolution
Hi, I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. However, when I use the res parameter of png() this is not what I see. Would someone show me how I can just increase the resolution without changing the physical sizes of elements in my plot? Maybe an example would help? Below are three images. I expect that if I print them out, let's say scaled to fit the page, then items such as the words Title Text would appear the same size. Instead (for the last two) it appears that the same number of pixels are being used, thus the text size appears smaller. What should I do to just increase the resolution? png(72dpi.png, width=6+2/3, height=6+2/3, units=in, res=72) plot(0,0, main=Title Text) dev.off() png(300dpi.png, width=6+2/3, height=6+2/3, units=in, res=300) plot(0,0, main=Title Text) dev.off() png(600dpi.png, width=6+2/3, height=6+2/3, units=in, res=600) plot(0,0, main=Title Text) dev.off() Thanks in advance, Matthew Walker __ 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.
Re: [R] PNG resolution
Matthew Walker wrote: I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. The sample you provided create figures with the same relative size of text and title on Windows and R 2.10.1. I remember, however, that I had similar problem before, so possibly it has been fixed and you are using an older version or a different operating system. Also have a look at the Cairo devices; I have used them with good success in similar cases. Dieter -- View this message in context: http://n4.nabble.com/PNG-resolution-tp1294757p1307877.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.
Re: [R] PNG resolution
Dieter Menne wrote: Matthew Walker wrote: I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. The sample you provided create figures with the same relative size of text and title on Windows and R 2.10.1. I remember, however, that I had similar problem before, so possibly it has been fixed and you are using an older version or a different operating system. Also have a look at the Cairo devices; I have used them with good success in similar cases. Thank you Dieter for your reply. I too am using R version 2.10.1 (2009-12-14), but on Linux. I compiled it against cairo-1.8.8. I tried specifying the cairo device by adding 'type=cairo' to the png() call, but it resulted in the same effect. I did notice, however, that the centre (0,0) circle is drawn at the same physical size for each of the examples. The same can be said of the outer box, and the tick marks. It is only the main text and the x and y labels that change in size. Is it possible that the text size is somehow dependant on the number of pixels in the image? Thanks again, Matthew __ 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.
Re: [R] png() resolution problem {was Silhouette ...}
Martin Maechler wrote: Hallo Sebastian, SP == Sebastian Pölsterl s...@k-d-w.org on Sun, 14 Jun 2009 14:04:52 +0200 writes: SP Hello Martin, SP I plotting the silhouette of a clustering and storing it as png. When I SP try to store the image as png the bars are missing. The bars are plotted SP when I use x11 or postscript as device. In addition, it seems to work SP when I use a smaller matrix (e.g. ruspini). SP Would be great if you have look at this issue. Hmm, I've been at a conference in Italy... The silhouette plot only uses standard R plotting functions, so any problem with it exposes problems in standard R graphics. -- Such a message should really go to R-help. to which I CC now. -- library(cluster) nmat - matrix(rnorm(2500*300), ncol=300, nrow=2500) rmat - matrix(rchisq(1000, 300, 50), ncol=300, nrow=1000) mat - rbind(nmat, rmat) pr - pam(mat, 2) sil - silhouette(pr) png(sil.png) #postscript(sil.ps) plot(sil) dev.off() -- Anyway, I can confirm the problem, but of course, it has not much to do with the silhouette function, but rather with the png() device which produces a bitmap, and the lines you draw are too fine (in the bitmap resolution) and so are rounded to invisible. You can reproduce the problem much more simply: set.seed(1); x - rlnorm(5000) png(bar.png);barplot(x,col=gray,border=0,horiz=TRUE);dev.off() system(eog bar.png ) ## which is also empty, and the completely analogue, replacing ## png [bitmap] with pdf [vector graphic] pdf(bar.pdf);barplot(x,col=gray,border=0,horiz=TRUE);dev.off() system(evince bar.pdf ) ## gives a very nice plot, into which you can zoom and see all details. Now in principle you should be able to use png() with a much higher resolution than the default one, but replacing the above png(bar.bng) with png(bar.bng, res = 1200) did not help, as we now get the infamous Error in plot.new() : figure margins too large Other R-help readers will be able to make the png() example work for such cases, where you need so many lines. {but let's stick with barplot(*, border=0, *)} Well, it's pretty hard, but one of the few cases where conversion from some vector image to the bitmap produces fair results, hence I'd use bitmap() with ghostscript to generate the png as in: bitmap(sil.png, type=pnggray, res=300) plot(sil) dev.off() Best, Uwe Regards, Martin Maechler, ETH Zurich __ 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. __ 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.
[R] png() resolution problem {was Silhouette ...}
Hallo Sebastian, SP == Sebastian Pölsterl s...@k-d-w.org on Sun, 14 Jun 2009 14:04:52 +0200 writes: SP Hello Martin, SP I plotting the silhouette of a clustering and storing it as png. When I SP try to store the image as png the bars are missing. The bars are plotted SP when I use x11 or postscript as device. In addition, it seems to work SP when I use a smaller matrix (e.g. ruspini). SP Would be great if you have look at this issue. Hmm, I've been at a conference in Italy... The silhouette plot only uses standard R plotting functions, so any problem with it exposes problems in standard R graphics. -- Such a message should really go to R-help. to which I CC now. -- library(cluster) nmat - matrix(rnorm(2500*300), ncol=300, nrow=2500) rmat - matrix(rchisq(1000, 300, 50), ncol=300, nrow=1000) mat - rbind(nmat, rmat) pr - pam(mat, 2) sil - silhouette(pr) png(sil.png) #postscript(sil.ps) plot(sil) dev.off() -- Anyway, I can confirm the problem, but of course, it has not much to do with the silhouette function, but rather with the png() device which produces a bitmap, and the lines you draw are too fine (in the bitmap resolution) and so are rounded to invisible. You can reproduce the problem much more simply: set.seed(1); x - rlnorm(5000) png(bar.png);barplot(x,col=gray,border=0,horiz=TRUE);dev.off() system(eog bar.png ) ## which is also empty, and the completely analogue, replacing ## png [bitmap] with pdf [vector graphic] pdf(bar.pdf);barplot(x,col=gray,border=0,horiz=TRUE);dev.off() system(evince bar.pdf ) ## gives a very nice plot, into which you can zoom and see all details. Now in principle you should be able to use png() with a much higher resolution than the default one, but replacing the above png(bar.bng) with png(bar.bng, res = 1200) did not help, as we now get the infamous Error in plot.new() : figure margins too large Other R-help readers will be able to make the png() example work for such cases, where you need so many lines. {but let's stick with barplot(*, border=0, *)} Regards, Martin Maechler, ETH Zurich __ 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.