[R] legend not appearing in Word document

Tim_Clark at nps.gov Tim_Clark at nps.gov
Fri Dec 17 02:03:33 CET 2010


I am starting to think the problem is the number of colors being used in
the legend when using Word 2007 and the eps file format.  I have played
around with the number of colors in mycol and found that it works for under
3000 colors (length mycol<3000), but I only get an empty (colorless) box
when using greater than 3000 colors.  I am not sure why 3000 would be a
cut-off, but by reducing my color pallet I have been able to get the legend
to open in Word 2007.  Word 2010 may allow for more colors, or treat colors
in a different way.  I haven't been able to test this out on different
machines, so it still could be specific to my machine for some reason.  The
eps format also converts well into pdf format.  I still haven't found a way
to get the wmf format to work correctly when converting it to pdf, so am
simply re-saving all of my figures in eps.



Tim Clark
Marine Ecologist
National Park of American Samoa
Pago Pago, AS  96799
Tim_Clark at nps.gov

             "Robert Baer"                                                 
             <rbaer at atsu.edu>                                              
             12/16/2010 07:30          "Duncan Murdoch"                    
             AM                        <murdoch.duncan at gmail.com>, "Tim    
                                       Clark" <mudiver1200 at yahoo.com>      
                                       "r help r-help"                     
                                       <r-help at r-project.org>, "Tim Clark" 
                                       <tim_clark at nps.gov>                 
                                       Re: [R] legend not appearing in     
                                       Word document                       

> On 12/12/2010 8:59 AM, Tim Clark wrote:
>> I need help with using graphics in Word 2007 that will later be
>> into a
>> pdf document.  I have tried several formats and found that I get the
>> quality of graphics using .wmf, .eps format, but when I convert it to
>> .pdf I get
>> a bunch of lines across the figures.  I also tried .tiff and .png but
>> they give
>> me much lower quality.  The best quality that converts to pdf appears to

>> be
>> .eps.  However, I have now come across a problem with my figure legends.

>> For
>> some reason the legend is visible in R but not in Word.  Does anyone
>> why a
>> legend in .eps format won't work in Word, or how I can get it to work?
>> have
>> made an example of the legend below that you should be able to save as
>> .eps and
>> paste into Word as an example.  I would appreciate any help you can
>> on
>> getting the legend in .eps format to work, or on other formats that may
>> be
>> better for Word and pdf files.
>> Thanks,
>> Tim
>>        library(plotrix)
>>        Satelite.Palette<-
>> colorRampPalette(c("blue3","cyan","aquamarine","yellow","orange","red"))
>>        mycol<-Satelite.Palette(ceiling(5000+1))#Max relative angle
>> multiplied by
>> 100 to give larger range.  Max is 3.1415, rounded up to 3.15 plus one.
>>        col.labels<-round((seq(0,5000,length.out=5)/1000),1)
>>        plot(0, 0, type="n", axes=F, xlab="", ylab="")   #New plot for
>> legend
>>        color.legend(0,0,1,1,col.labels, mycol, align="rb", gradient="y")

>> #Adds
>> legend
> I don't have Word 2007, but when I execute that code I get a legend
> on screen or in an EPS file.  So this looks like a Word bug; you'll need
> to talk to Microsoft.
> Duncan Murdoch

For what it is worth, I just tried importing the .eps legend into Word 2010

and it seemed to work fine suggesting that MS may have updated their .eps
import driver with that version of Office?


More information about the R-help mailing list