[R] tweak a bit the legend wiht ggplot2

hadley wickham h.wickham at gmail.com
Fri Jul 31 15:49:01 CEST 2009


Hi Benoit,

Unfortunately there's currently no way to do that - the legend
automatically corresponds to the geom in the plot.

Hadley

On Thu, Jul 23, 2009 at 11:30 AM, Benoit
Boulinguiez<benoit.boulinguiez at ensc-rennes.fr> wrote:
> Hi all,
>
> I've this ggplot2 graph
> (http://www.4shared.com/file/120101043/f3e9350/isotherm.html).
>
> I'd like to tweak the legend for the adsorbent part. I'd like to have full
> square of the colors instead of the full circles.
> I guess that I've to work on the scale_color_hue or fill somewhere but I
> haven't found my way yet.
>
> Here is my code to get the graph:
>
> pdf("isotherm.pdf",width=7,height=6)
>
> #windows(width=7,height=6)
> ads.graph<-ggplot(Adsorp.DATA,aes(relative.p,ads.vol,shape=type
>   ,color=adsorbent))+
>
>  geom_point(size=I(3)) +
>
>  labs(x=expression(p/p[0]),y=N[2]~adsorbed~volume~(cc/g)) +
>
>  scale_shape(name="Adsorption\nProcedure"
>  ,solid=F
>  ,breaks=c("A","D")
>  ,labels=c("Adsorp.","Desorp.")
>  ) +
>
>  scale_colour_hue(name="Adsorbent") +
>
>  scale_x_continuous(limits=c(0,1),minor_breaks = seq(0,1,0.1)) +
>  scale_y_continuous(limits=c(0,1000)) +
>
>  opts(panel.grid.minor = theme_line(colour = "grey94"))
>
> print(ads.graph)
> dev.off()
>
>
>
> Regards/Cordialement
>
> -------------
> Benoit Boulinguiez
> Ph.D student
> Ecole de Chimie de Rennes (ENSCR) Bureau 1.20
> Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes"
> Avenue du Général Leclerc
> CS 50837
> 35708 Rennes CEDEX 7
> Tel 33 (0)2 23 23 80 83
> Fax 33 (0)2 23 23 81 20
>  <http://www.ensc-rennes.fr/> http://www.ensc-rennes.fr/
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
>



-- 
http://had.co.nz/




More information about the R-help mailing list