[R-SIG-Mac] How to put nice R graphics into powerpoint
chabotd at globetrotter.net
Sun Feb 13 11:36:46 CET 2005
Simon, many thanks for your very informative answer.
I have pretty much given up the idea of converting to vector-based pict
by lack of a tool to do the work. A last attempt was with MacGhostview.
I'm not sure what the result is. It must be a vector based pict because
it remains sharp even at maximum zoom in PowerPoint. However lines and
plot symbols are not smooth and therefore the plots are not very
I have tried the new tool you offered to us, pstoedit. It produced
results "close to good enough" with my plots. Lines and symbols were
very thin, like in hairline line thickness, but maybe different
settings in pstoedit would fix this. However I showed results of GAM
fits with the confidence bands displayed, and in the converted plot the
confidence bands were not clipped at the axes but continued in the
margins. Furthermore text rotated 90 degrees (vertical text) required
editing or moving, hence each plot would require quite a bit of work.
For the rest, I added some comments in answer to your message.
Le 12 févr. 2005, à 12:00, r-sig-mac-request at stat.math.ethz.ch a écrit :
> Message: 1
> Date: Fri, 11 Feb 2005 11:12:08 -0500
> From: Simon Urbanek <simon.urbanek at r-project.org>
> Subject: Re: [R-SIG-Mac] How to put nice R graphics into powerpoint
> To: Phillip Price <pnprice at lbl.gov>
> Cc: r-sig-mac at stat.math.ethz.ch
> Message-ID: <AE1FF99A-7C47-11D9-B113-000D93AE1C66 at r-project.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> Hi Phil,
> some of the discussion went into private e-mails so I guess I'll fill
> some pieces here for the list.
> On Feb 10, 2005, at 5:34 PM, Phillip Price wrote:
>> I usually create a PDF with R, and import it into Powerpoint for the
>> mac. The results are fuzzy and not good. I don't have Illustrator.
>> For final presentations I sometimes send the pdf to a colleague who
>> has Illustrator, who converts it for me.
> It's better to use PhotoShop (if you have it) than Illustrator - AI
> doesn't handle objects with alpha component well and has some other
> quirks. PS rendered all graphics I had perfectly and allows flexible
> resolution settings and many more output formats.
My pdf plot did not use the alpha channel (at least I did not
consciously ask for this). The png produced by Illustrator and
Photoshop were equally nice after importing in PowerPoint, but
Illustrator was faster at opening the pdf and saving the png. The size
in pixels was a bit different, but when displayed at the same size in
PowerPoint I could not tell them apart. Both these png had a
transparent background. But one thing was weird for both of them: the
symbols in my plot had varying sizes because I used a 3rd variable to
control cex. The png files produced by Illustrator and Photoshop were
much smaller than those of the original pdf. Weird (and undesirable!).
Converting from pdf to png with Preview did not produce very good
results. But my best results came from doing the conversion with
Acrobat 7. Very sharp looking png with symbols being exactly the same
size as in the pdf file. The background is white instead of
transparent, I don't know why. This I'm less happy with as I sometimes
need a transparent background, but for this particular presentation
white is OK.
I looked a bit more carefully at the size of my symbols and noticed
that they are different between quartz device and pdf device for the
same script on the same data. Is this documented somewhere that I did
not think to check?
> Other solution is to use R directly to produce hi-res bitmaps instead
> of PDF. You'll need to tweak the settings to get a good output, though.
Yes, this was my first choice after giving up vector pict.
For this to have been practical, I would have liked to have just one
line to change from the script building a pdf file (I'll always need
that format). Unfortunately, if you just replace pdf by png and do not
change anything else, the result (480 x 480 @ 72 dpi) is not
particularly crisp in PowerPoint. But if you start to ask for more
pixels, all your settings have to be changed or you get tiny text and
symbols and thin lines. This is too bad, although it is very possible I
am doing something wrong with the png command. But for now I have to
change so many aspects of my plots, which I carefully adjusted for a
nice looking pdf, that it is not the best option for me.
>> For weeks I've been intending to find a better way to do things,
>> assuming that there must already be a solution in the R community and
>> that I had just been too lazy to track it down. If, instead, the
>> actual state of things is that R cannot produce output that can be
>> used well in the world's most popular presentation software, then I
>> think this should be a fairly high-priority item. (Of course, I say
>> this from the standpoint of someone who will not actually be doing the
>> work to implement a change, so, easy for _me_ to say)!
> The fact is that R can produce "output that can be used well in the
> world's most popular presentation software" if you're using the
> "world's most popular" operating system. That is the reason why it
> becomes a very low priority item as your argument backfires ;).
> For the record - Cocoa doesn't support PICT (neither vector nor
> raster), so we can't go that way. Carbon + QuickDraw supports PICT, but
> that GD is very old and incompatible with the current R - bad luck
> again (volunteers are free to take the old code, port it to the current
> R and add PICT support...). Another possibility would be to tweak the
> Win32 R code and use libEMF - again a lot of work that may or may not
> lead to the desired result.
> Finally some good news ;). After some tweaking and bug-fixing I was
> able to compile pstoedit and libEMF for OS X. The output isn't exactly
> great, but people who can live with PowerPoint won't notice or mind
> either, so there it goes:
> That's the binary (statically linked, so nothing else needed). Just
> download, run
> chmod a+x pstoedit
> on it in Terminal after downloading and you're ready to go. It's a
> command-line tool, of course, and I highly recommend using the -pta
> flag. Furthermore due to the limitations of EMF format, you may be
> better off scaling the image to get somewhat more reasonable result, so
> you could use something like:
> pstoedit -pta -xscale 16 -yscale 16 test.pdf test.emf
> The reason why scaling makes a difference is that EMF uses integer
> precision and the grid of possible points is very coarse by default.
> BTW: although the name says "ps..." it actually works much better with
> R's PDF files than PS. Chances are that you'll need GhostScript in
> /usr/local/bin - but I guess everyone has that, right?
> In conclusion I can't help but to say, get Keynote if you can - you'll
> save yourself a lot of work and you presentation will look nicer than
> everyone else's that use PP (in terms of rendering and features - the
> content is still up to you ;)). If people insist that you use a PC for
> presentation, you can still use QT without compromising the quality of
> your talk. (Any flames in PT, please ;)).
More information about the R-SIG-Mac