[R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel

Hello
I don't arrive to change the title of the legend
My code is :
library(ggplot2)
ma <- max(General$AgeChangCat) ; mi <- min(General$AgeChangCat)
Test$Recrutement <- factor(Test$CadNonCadRecrut)
p <-
ggplot(Test, aes(x=factor(Cat1), y=AgeChangCat )) +
ylim(mi,ma) +
geom_point() +
geom_boxplot(aes(fill = Recrutement)) +
labs(title = "Age", x="catégorie", y="Age") +
theme(legend.position = c(0.1,0.9), legend.background = 
element_rect(colour = "black"))

p

any idea ?

--
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31

__
R-help@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.


Re: [R] ggplot2 : to change the title of legend

2013-10-11 Thread PIKAL Petr
Hi

I usually use scale

something like
scale_fill_discrete(name = "Fancy Title")
shall do the trick

Regards
Petr


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Arnaud Michel
> Sent: Friday, October 11, 2013 11:02 AM
> To: R help
> Subject: [R] ggplot2 : to change the title of legend
> 
> Hello
> I don't arrive to change the title of the legend My code is :
> library(ggplot2)
> ma <- max(General$AgeChangCat) ; mi <- min(General$AgeChangCat)
> Test$Recrutement <- factor(Test$CadNonCadRecrut) p <- ggplot(Test,
> aes(x=factor(Cat1), y=AgeChangCat )) +
> ylim(mi,ma) +
> geom_point() +
> geom_boxplot(aes(fill = Recrutement)) +
> labs(title = "Age", x="catégorie", y="Age") + theme(legend.position =
> c(0.1,0.9), legend.background = element_rect(colour = "black")) p
> 
> any idea ?
> 
> --
> Michel ARNAUD
> Chargé de mission auprès du DRH
> DGDRD-Drh - TA 174/04
> Av Agropolis 34398 Montpellier cedex 5
> tel : 04.67.61.75.38
> fax : 04.67.61.57.87
> port: 06.47.43.55.31
> 
> __
> R-help@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.

__
R-help@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.


Re: [R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel

OK It is right
Thank you Petr
Michel
Le 11/10/2013 14:58, PIKAL Petr a écrit :

Hi

I usually use scale

something like
scale_fill_discrete(name = "Fancy Title")
shall do the trick

Regards
Petr



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Arnaud Michel
Sent: Friday, October 11, 2013 11:02 AM
To: R help
Subject: [R] ggplot2 : to change the title of legend

Hello
I don't arrive to change the title of the legend My code is :
library(ggplot2)
ma <- max(General$AgeChangCat) ; mi <- min(General$AgeChangCat)
Test$Recrutement <- factor(Test$CadNonCadRecrut) p <- ggplot(Test,
aes(x=factor(Cat1), y=AgeChangCat )) +
ylim(mi,ma) +
geom_point() +
geom_boxplot(aes(fill = Recrutement)) +
labs(title = "Age", x="catégorie", y="Age") + theme(legend.position =
c(0.1,0.9), legend.background = element_rect(colour = "black")) p

any idea ?

--
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31

__
R-help@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.




--
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31

__
R-help@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.