[R] xfig boxplot (polygon) bug??

Prof Brian D Ripley
Tue, 13 Feb 2001 07:28:59 -0000

On Tue, 13 Feb 2001 e.catchpole at adfa.edu.au wrote:

> There appears to be a bug in the R xfig() driver.
>
> When I run a simple example, eg
>
> > data(InsectSprays)
> > boxplot(count ~ spray, data = InsectSprays, col =
"lightgray")
>
> the boxplot is fine. Doing the same thing after
>
> > xfig(file='test.fig')
>
> and then opening in Xfig (ver3.2 patchlevel 2) on my Linux box produces
boxplots
> where the boxes, although correctly shaded in, have
> lost the vertical line that defines the left edge of the box. That is,
> they look like
>
>        |                         |
>        |                         |
>      -----                     -----
>           |                   |     |
>           |    instead of     |     |
>           |                   |     |
>      -----                     -----
>        |                         |
>        |                         |
>
> This doesn't sound serious, but I'm running the result through pdf
> postprocessors (mpost, then ppower4), and the result comes out as
> triangles instead of boxes!

The bug is in the documentation of the drivers: their Polygon function is
documented as

        /* device_Polygon should have the side-effect that a    */
        /* polygon is drawn using the given x and y values      */
 ...

but as I discovered when writing the PDF driver, this actually
means `and closing the path'.   XFig interprets it differently.


> A simple workaraound, I expect, would be to define the boxes as
> 5-point polygons rather than 4-point, to force closure (sorry if I'm
> not using the right jargon here).

Yes.

> I tried to get a look at the boxplot code to check this out, but
>
> > boxplot
>
> just produces
>
> function (x, ...)
> UseMethod("boxplot")
>
> Is there any way I can get at the boxplot code? Or is there another
> way out of my problem? I'd be very grateful for any help.

Look at boxplot.default.  It will not help though, as it is buried in the
driver code.

> I'll post this as a bug if this is confirmed.

Don't trouble yourself: it is already fixed in R-patched and hence will be
in 1.2.2.

>
> Thanks,
> Ted.
>
> Dr E.A. (Ted) Catchpole
> School of Maths & Stats                Honorary Senior Research Fellow
> University College, UNSW               Institute of Maths & Stats
> Australian Defence Force Academy       University of Kent at Canterbury
> Canberra, ACT 2600, Australia          Canterbury CT2 7NF, England
> e-catchpole at adfa.edu.au                E.A.Catchpole at ukc.ac.uk
> www.ma.adfa.edu.au/~eac
> fax: +61 2 6268 8886
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at
stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595