[R] Yet another plotting hint - choosing the proper device to produce plots for Word

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Aug 13 14:34:08 CEST 2009


On Thu, 2009-08-13 at 04:53 -0700, Jason Rupert wrote:
> Scott, 
> 
> Thanks for your response and insight. 
> 
> I call what I'm seeing - "Not coloring within the lines" :)
> 
> When using pch 19, 20, or 21, it looks like the fill does no stay
> within the perimeter of the circle or properly fill the circle, i.e.
> some blank area left.  It is demonstrated at the following Nabble post
> location:    
> 
> http://n2.nabble.com/Unusual-Plotting-Artifacts-td3437365.html
> 
> I guess I would like to use a device that does not have this issue and
> also provides image that look well electronically in Word and also
> print well.  They need to look good when importing because most of the
> reviews will be conducted electronically in Word, and it needs to look
> good when printed because one or two folks will review a hard copy.

I wouldn't be so quick to blame the device itself - the rendered could
also be having difficulties with metafiles, even MS own software has
problems.

>   
> 
> You mentioned that EPS has a weakness because Word shows a low
> resolution version.  Is there another device that gets around this
> problem?  At this point filesize is not an issue.

You could add the preview yourself using ghostscript and gsview on
Windows - IIRC you get a few options as to how the preview should be
generated. It is still going to be low-res though, compared to the
printed version.

Ultimately, vector based images are going to render better when printed
throughout this process, so think about the ultimate delivery of this
document and ease of conversion to things like PDF if that is on the
cards. Bitmap images (PNG etc) might look good on screen but print
poorly or loose resolution if manipulated etc.

Depends on the work flow you have in mind, but perhaps a high res PNG or
TIFF might be better if file size is irrelevant if you have to use Word
and have to review on screen.

G

>   
> 
> Thank you again for all your help and feedback.    
> 
> 
> 
> 
> 
> --- On Thu, 8/13/09, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
> 
> > From: Gavin Simpson <gavin.simpson at ucl.ac.uk>
> > Subject: Re: [R] Another Plotting Hint - changing fill color for points
> > To: "Scott Sherrill-Mix" <shescott at mail.med.upenn.edu>
> > Cc: "Jason Rupert" <jasonkrupert at yahoo.com>, r-help at r-project.org
> > Date: Thursday, August 13, 2009, 3:41 AM
> > On Wed, 2009-08-12 at 23:36 -0400,
> > Scott Sherrill-Mix wrote:
> > > I don't really use Word or .wmf but maybe try a high
> > pixel count .png e.g.
> > > png('test.png',height=480*5,width=480*5,res=72*5)
> > > plot(1:10, col = "red", bg = "grey", pch=21, cex
> > =1.7)
> > > dev.off()
> > > 
> > > 
> > > Scott
> > 
> > An EPS is likely to give better resolution if the document
> > is intended
> > to be printed. An EPS image will likely also have a much
> > smaller file
> > size, if that is important.
> > 
> > One problem with EPS files in Word is that, at least in the
> > versions I
> > have used (up to Office 11), Word displays a low resolution
> > preview of
> > the image on screen, so it doesn't look quite so good on
> > screen, but
> > printing is fine.
> > 
> > Jason, did you print your document containing the wmf? What
> > you might be
> > seeing could just be the effects of antialiasing or some
> > other
> > processing going on to display the image in Word on screen
> > and not be
> > present in the printed version.
> > 
> > To get an eps, use postscript() with 'paper' and 'onefile'
> > set
> > appropriately
> > 
> > eps('test.eps' height = 6, width = 7, pointsize = 10,
> >     paper = "special", onefile = FALSE)
> > ## plotting
> > dev.off()
> > 
> > HTH
> > 
> > G
> > 
> > > 
> > > Scott Sherrill-Mix
> > > Department of Microbiology
> > > University of Pennsylvania
> > > 402B Johnson Pavilion
> > > 3610 Hamilton Walk
> > > Philadelphia, PA  19104-6076
> > > 
> > > 
> > > 
> > > On Wed, Aug 12, 2009 at 6:17 PM, Jason Rupert<jasonkrupert at yahoo.com>
> > wrote:
> > > > This worked great.
> > > >
> > > >
> > > > Regarding the second question - can you expound a
> > bit more on the effect of the device?  Right now, as
> > shown by the test code because I am on a Windows machine and
> > need to import the image to Word I am using WMF.  Is
> > there a better device that I should use that will help with
> > the presolution of the points that are drawn?  For
> > example, I can see white pixesl on the blue circles, and
> > notice that is not a perfect circle.  Thanks for any
> > information about a better way to go:
> > > >
> > > >
> > win.metafile(file=as.character(figure_file_name_and_path),
> > pointsize = 10)
> > > > plot(-4:4, -4:4, type = "n")# setting up coord.
> > system
> > > > points(vals_201, vals_200, col = "red", bg =
> > "grey", pch=21, cex =1..7)
> > > > #points(vals_201, vals_200, col = "grey", bg =
> > "white", pch=21, cex =1.5)
> > > > points(rnorm(100)/2, rnorm(100)/2, col = "blue",
> > bg = "blue",  pch=21, cex =1.5)
> > > > dev.off()
> > > >
> > > >
> > > > Thanks again.
> > > >
> > > > --- On Wed, 8/12/09, Sarah Goslee <sarah.goslee at gmail.com>
> > wrote:
> > > >
> > > >> From: Sarah Goslee <sarah.goslee at gmail.com>
> > > >> Subject: Re: [R] Another Plotting Hint -
> > changing fill color for points
> > > >> To: "Jason Rupert" <jasonkrupert at yahoo.com>,
> > "r-help" <r-help at r-project.org>
> > > >> Date: Wednesday, August 12, 2009, 4:56 PM
> > > >> Yes, you can do that. You need to
> > > >> specify pch in the range of 21-25,
> > > >> and can then
> > > >> specify both col and bg (background color).
> > Oddly, the help
> > > >> for this option is
> > > >> under ?points rather than ?par or ?pch, but
> > there are many
> > > >> examples.
> > > >>
> > > >> Your second question would depend heavily on
> > the device you
> > > >> use and its
> > > >> associated settings, but using the above
> > solution should
> > > >> solve your problem.
> > > >>
> > > >> Sarah
> > > >>
> > > >> On Wed, Aug 12, 2009 at 5:29 PM, Jason
> > Rupert<jasonkrupert at yahoo.com>
> > > >> wrote:
> > > >> >
> > > >> > Is it possible to change the fill color
> > of a point?
> > > >>  For example, the outer color being
> > "Blue" and inner color
> > > >> being "Grey".
> > > >> > I've tried changing "col" and "bg", but
> > that does not
> > > >> seem to have the desired effect.
> > > >> >
> > > >> > Below is another attempt, but the pixel
> > resolution of
> > > >> the points function does not appear to be
> > high enough for
> > > >> this to work:
> > > >> >
> > > >> >
> > figure_file_name_and_path<-paste("Test.wmf",
> > > >> sep="")
> > > >> >
> > > >> > vals_200<-rnorm(200)
> > > >> > vals_201<-rnorm(200)
> > > >> >
> > > >> >
> > > >>
> > win.metafile(file=as.character(figure_file_name_and_path),
> > > >> pointsize = 10)
> > > >> > plot(-4:4, -4:4, type = "n")# setting up
> > coord.
> > > >> system
> > > >> > points(vals_201, vals_200, col = "blue",
> > bg = "white",
> > > >> pch=19, cex =1.7)
> > > >> > points(vals_201, vals_200, col = "grey",
> > bg = "white",
> > > >> pch=19, cex =1.5)
> > > >> > points(rnorm(100)/2, rnorm(100)/2, col =
> > "blue", bg =
> > > >> "white",  pch=19, cex =1.5)
> > > >> > dev.off()
> > > >> >
> > > >> > As a second question, is there any way
> > to increase the
> > > >> pixel resolution of the points produced on
> > the plot so that
> > > >> they are perfect circles.  I just
> > noticed that the fill
> > > >> does not perfectly fill the points on the
> > plot and there are
> > > >> some pixels outside the circle.
> > > >> >
> > > >> > Thanks again.
> > > >> >
> > > >>
> > > >>
> > > >> --
> > > >> Sarah Goslee
> > > >> http://www.functionaldiversity.org
> > > >>
> > > >
> > > >
> > > >
> > > >
> > > > ______________________________________________
> > > > R-help at 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 at 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.
> > -- 
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> >  Dr. Gavin Simpson         
> >    [t] +44 (0)20 7679 0522
> >  ECRC, UCL Geography,          [f]
> > +44 (0)20 7679 0565
> >  Pearson Building,         
> >    [e] gavin.simpsonATNOSPAMucl.ac.uk
> >  Gower Street, London          [w]
> > http://www.ucl.ac.uk/~ucfagls/
> >  UK. WC1E 6BT.           
> >      [w] http://www.freshwaters.org.uk
> > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> > 
> > 
> > 
> 
> 
> 
> 
> ______________________________________________
> R-help at 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list