Thanks Brian. That worked. I also wanted to increase the size of the
'points' on the graph. Is there any way I can get rid of the 'legend' (in
this case '3') appearing on the plot?
======= code ====
library(ggplot2)
leaves <- letters[1:8]
mat <- matrix(sample(1:1000,32),nrow=16,ncol=2)
colnames(mat) <- paste('t',1:2,sep='')
df <- as.data.frame(cbind(mat,leaves))
vals <- 1:length(leaves)
names(vals) <- leaves
p <- ggplot(df,aes(t1,t2))
p + aes(shape = factor(leaves)) + geom_point(aes(colour =
factor(leaves),size=3)) + scale_shape_manual(values=vals)
=========
thanks!
On Mon, Apr 16, 2012 at 3:09 PM, Brian Diggs <[email protected]> wrote:
> On 4/16/2012 7:31 AM, Brian Smith wrote:
>
>> Hi,
>>
>> I was trying to replicate one of the graphs given on the ggplot2 website.
>> I
>> have given a sample code below. I would like to combine the legends, since
>> each color is uniquely mapped to a shape.
>>
>> ###
>> library(ggplot2)
>>
>> leaves<- letters[1:8]
>> mat<- matrix(sample(1:1000,32),nrow=**16,ncol=2)
>> colnames(mat)<- paste('t',1:2,sep='')
>> df<- as.data.frame(cbind(mat,**leaves))
>>
>> vals<- 1:length(leaves)
>> names(vals)<- leaves
>>
>> p<- ggplot(df,aes(t1,t2))
>> p + aes(shape = factor(leaves)) + geom_point(aes(colour =
>> factor(leaves))) + scale_shape_manual("",values=**vals)
>>
>> ####
>>
>> Which parameter do I need to change?
>>
>
> add scale_colour_discrete("") to your call. In order for scales to be
> combined, the breaks, labels, and title must all be the same. You had
> breaks and labels the same, but not the title. Alternatively, change the
> scale_shape_manual call to scale_shape_manual(values=**vals).
>
>
> thanks!
>>
>
>
> --
> Brian S. Diggs, PhD
> Senior Research Associate, Department of Surgery
> Oregon Health & Science University
>
> ______________________________**________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.