[R] pie EPS BB

(Ted Harding) Ted.Harding at manchester.ac.uk
Wed Mar 10 23:36:23 CET 2010


On 10-Mar-10 22:19:13, Marc Schwartz wrote:
> On Mar 10, 2010, at 4:03 PM, Ted Harding wrote:
> 
>> Greetings all!
>> I'm facing a puzzle I have not been able to solve.
>> I need to make an EPS of a pie-chart (Yes, I know;
>> please don't bother to tell me! I just need to ...).
>> 
>> I'm trying to do it with pie(), and I want to have
>> just the plain pie-chart with no annotations. So far
>> so good: "labels=rep(NA,...)" will do it.
>> 
>> But I want to have it output to an EPS file with the
>> BoundingBox *exactly* containing the pie-chart, i.e.
>> the pie-chart boundary touches the four sides of the
>> BoundingBox, and its centre is at the centre of the
>> BoundingBox. This is the puzzle I have not been able
>> to solve.
>> [mucho snippo]
>> By way of background: I want to include the EPS file in a
>> document where I would use graphics commands to embellish
>> the pie-chart with my own annotations. For this I need to
>> be able to calculate the cordinates of points on the chart
>> relative to its centre; whereas the software will be using
>> the BoundingBox to locate the imported graphic. So I have
>> to be able to work out the coordinates of the pie-chart
>> relative to the BoundingBox. The PostScript code in the EPS
>> file is difficult to decipher from this point of view, so
>> (as explained) I have been reduced to editing the Bounding
>> Box until it looks about right.
>> 
>> Sorry for the long account, but I wanted to try to make the
>> situation clear.
>> 
>> With thanks for any suggestions!
>> Ted.
> 
> 
> Ted, try this:
> 
> pcts <- c(3.0, 2.0, 0.4, 10.0, 12.0, 3.0, 39.0, 14.0,
>           7.0, 9.6)
> postscript("piecharttest.eps", horizontal = FALSE,
>            onefile = FALSE, paper = "special", 
>            width = 3.0, height = 3.0)
> par(mar = c(0, 0, 0, 0), xaxs = "i", yaxs = "i")
> pie(pcts, clockwise = TRUE, labels = rep(NA, 10), 
>     radius = 1.0)
> dev.off()
> 
> Two things:
> 1. Set the margins to 0 on all four sides and set the axes to 'i' so
> that they don't expand by the default 4%.
> 2. You forgot the 'onefile = FALSE' in the call to postscript().
> 
> HTH,
> Marc Schwartz

That looks absolutely spot-on, Marc! Many thanks. I might have
found the "onefile" for myself, but the "mar", "xaxs" and "yaxs"
pars might have eluded me for some time.
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Mar-10                                       Time: 22:36:20
------------------------------ XFMail ------------------------------



More information about the R-help mailing list