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. Here is an example of the sort of thing I have been trying. 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, paper="special",width=3.0,height=3.0) pie(pcts, clockwise=TRUE, labels=rep(NA,10), radius=1.0) dev.off() With pie(pcts, clockwise=TRUE, labels=rep(NA,10), radius=1.0) lines(c(-1,1,1,-1,-1),c(-1,-1,1,1,-1)) I can see that the chart exactly fits inside a box with side 2 and centre (0,0). So far so good. But this box is not centred in the X-window device (somewhat up, and somewhat to the right, from centre). The result from the above postscript() command is a file with %%DocumentMedia: special 216 216 0 () () %%BoundingBox: 0 0 216 216 (where of course "216" means 3*72 points = 3 inches), and when this is displayed (using 'gv') I see the pie-chart distinctly offset from the centre of the BoundingBox, with its leftmost point at approx X=84 points from the left of the box (at 0), its rightmost point at X=162 approx 54 points from the right of the box (at 216), so the diameter of the circle is approx 162-84 = 78 points (a bit over 1 inch), and the centre of the circle is approx at 123 points (X) which is 15 points to the right of the centre of the box. Similarly the top of the circle is at approx Y=156 (60 points from the top of the box) and the bottom is at approx Y=78 from the bottom of the box. So, although relative dimensions are about right as measured, the pie-chart is off-centre relative to the BoundingBox, just as when displayed in the X-window. I have been able to re-write the %%BoundinBox line by editing the EPS file until it looks about right, and can then continue. However, I would like to be able to exactly enclose the pie chart in the BoundingBox automatically, but the documentation (in ?pie and in ?postscript) seems to contain nothing that would give me a clue for achieving this. 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. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 10-Mar-10 Time: 22:03:41 ------------------------------ XFMail ------------------------------ ______________________________________________ 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.