[R] ggplot2: scale_shape_manual

Brian Smith
Mon, 16 Apr 2012 14:31:37 -0000

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?

thanks!

	[[alternative HTML version deleted]]