[R] bottom legends in ggplot2 ?

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Feb 27 11:15:47 CET 2009

I would think that the lines below should work but they give an error.
Hadley, can you clarify this?



> library(ggplot2)
> qplot(mpg, wt, data=mtcars, colour=cyl) + opts(legend.position =
Error in grid.Call.graphics("L_setviewport", pvp, TRUE) : 
  Non-finite location and/or size for viewport
> ggplot(mtcars, aes(x = mpg, y = wt, colour = cyl)) + geom_point() +
opts(legend.position= "bottom")
Error in grid.Call.graphics("L_setviewport", pvp, TRUE) : 
  Non-finite location and/or size for viewport
> sessionInfo()
R version 2.8.1 (2008-12-22) 


attached base packages:
[1] grid      stats     graphics  grDevices datasets  utils     methods

[8] base     

other attached packages:
[1] ggplot2_0.8.1 reshape_0.8.2 plyr_0.1.5    proto_0.3-8  

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens Avram Aelony
Verzonden: donderdag 26 februari 2009 20:34
Aan: r-help at stat.math.ethz.ch
Onderwerp: [R] bottom legends in ggplot2 ?

Has anyone had success with producing legends to a qplot graph such that
the legend is placed on the bottom, under the abcissa rather than to the
right hand side ?

The following doesn't move the legend:
       qplot(mpg, wt, data=mtcars, colour=cyl,
gpar(legend.position="bottom") )

I am using ggplot2_0.8.2.

Thanks in advance,


R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

More information about the R-help mailing list