[R] Legend on plots when using Cairo

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 8 12:08:20 CEST 2008


Why are you using Cairo 'to avoid some X11 issues' for an unreleased 
version of R that does not use X11 for its png() device?

I see this under Cairo, but not under png(type ="cairo") (the default). 
The R posting guide asked you to discuss package problems with the 
maintainer, so if you have not already done so, please do so.

On Tue, 8 Apr 2008, audrey wrote:

> Dear all,
>
> I am trying to use the Cairo package to avoid some X11 issues and it
> works very well. However, when I want to add a legend to my plots, I
> receive an error message from Cairo:
>
> > library(Cairo)
> > CairoPNG(file="test.png")
> > plot(1:100)
> > dev.off()
> null device
>          1
> This works fine. But:
>
> > CairoPNG(file="test.png")
> > plot(1:100)
> > legend(50,50,"test")
> Error in strwidth(legend, units = "user", cex = cex) :
>  font 2147483647 not recognized in Rcairo_setup_font
> > dev.off()
> null device
>          1
>
> Does anyone know how to obtain a plot with legend using Cairo?
>
> I have tried it on two different environments, so here are the two
> sessionInfo():
>
> > sessionInfo()
> R version 2.8.0 Under development (unstable) (2008-04-07 r45137)
> i686-pc-linux-gnu
>
> locale:
> C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] Cairo_1.4-2    fortunes_1.3-3
>
> ###############
> > sessionInfo()
> R version 2.8.0 Under development (unstable) (2008-04-07 r45137)
> x86_64-unknown-linux-gnu
>
> locale:
> LC_CTYPE=en_US.ISO-8859-1;LC_NUMERIC=C;LC_TIME=en_US.ISO-8859-1;LC_COLLATE=en_US.ISO-8859-1;LC_MONETARY=C;LC_MESSAGES=en_US.ISO-8859-1;LC_PAPER=en_US.ISO-8859-1;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.ISO-8859-1;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] Cairo_1.4-2    fortunes_1.3-3
>
> Best regards,
> Audrey
>
> ______________________________________________
> R-help at 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.
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list