[R-sig-eco] Change ggplot legend

Stijn Van Hoey stvhoey.vanhoey at ugent.be
Thu Apr 16 11:43:28 CEST 2015


Why don't you just adapt it in the dataframe and make sure the levels in 
the Sp column are renamed to "Sp1" and "Sp2"?
http://www.cookbook-r.com/Manipulating_data/Renaming_levels_of_a_factor/

grs,
Stijn

On 04/16/2015 11:26 AM, Roman Luštrik wrote:
> Can you provide a reproducible example (using some available dataset or
> simulate some data) and perhaps mark on the picture what you want to have
> changed?
>
> Cheers,
> Roman
>
>
> On Thu, Apr 16, 2015 at 11:11 AM, Luis Fernando García <luysgarcia at gmail.com
>> wrote:
>> Dear R experts,
>>
>> I am trying to make a new plot. I have already finished and I just want to
>> change the color for the axis number and the legends, I have tried to make
>> the last function by removing the legend and adding a new one but it did
>> not work.
>>
>> If any of you knows how to correct this, I would really appreciate it. My
>> aim is to rename the series as "Sp1" and "Sp2".
>>
>> Thanks in advance!
>>
>> HEre is the plot code
>>
>> p <- ggplot(t,aes(x=Ratio,y=Time)) + geom_point(aes(shape=factor(Sp)))
>>
>> p + geom_smooth(aes(linetype=factor(Sp), ),colour="black", method='lm',
>> se=F)+theme(panel.grid.major = element_blank(), panel.grid.minor =
>> element_blank(),panel.background = element_blank(), axis.line =
>> element_line(colour = "black"))+
>>
>> theme(legend.position="none")+#Remove legend to add a new one
>>
>> scale_shape_discrete(name  ="Species",labels=c("Sp1", "Sp2"))
>>
>>          [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>
>

-- 
--
ir. Stijn Van Hoey
BIOMATH
Department of Mathematical Modelling, Statistics and Bioinformatics
Ghent University - Faculty of Bioscience Engineering
Coupure Links 653, 9000 Gent, Belgium
TEL: +32 (0)9 264 5935



More information about the R-sig-ecology mailing list