Quantcast

PNG resolution

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PNG resolution

Matthew Walker-3
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PNG resolution

Dieter Menne
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [R] PNG resolution

Matthew Walker-3

   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
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [R] PNG resolution

Joshua Wiley-2
In reply to this post by Matthew Walker-3
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
<[hidden email]>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
>
> ______________________________________________
> [hidden email] 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/

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PNG resolution

Matthew Walker-3

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PNG resolution

Matthew Walker-3
In reply to this post by Joshua Wiley-2
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
> <[hidden email] <mailto:[hidden email]>> 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
>
>     ______________________________________________
>     [hidden email] <mailto:[hidden email]> 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/

______________________________________________
[hidden email] 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.
Loading...