I am trying to plot two sets of points using two colors. The second
set is much smaller than the first set, so when I plot them, we cannot
really see the second set among all the points. Here is an example
library("ggplot2")
N1 <- 10000
N2 <- 10
myData1 <- data.frame(x=
rnorm(N1,6,3),y=runif(N1),condition=rep("treatment",N1))
myData2 <- data.frame(x= rnorm(N2,6,3),y=runif(N2),condition=rep("control",N2))
allData <- rbind(myData1,myData2)
library(ggplot2)
p <- ggplot(allData,aes(x=x,y=y,colour=factor(condition)))
p <- p + geom_point()
p
To work around this, I used layers. But then I lose the legend
indicating what the color corresponds to.
library(ggplot2)
p <- ggplot(myData1,aes(x=x,y=y))
p <- p + geom_point(alpha=0.1)
p <- p + layer(data=myData2,mapping=aes(x=x,y=y),geom='point',colour='red')
p
Any suggestions on how to improve my plot. Thanks!
Juliet
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
This works, more or less ... although I think it's a bit of an
accident. Couldn't figure out the equivalent of scale_alpha_manual,
although I guess one could hack up a way to use scale_alpha_identity ...
ggplot(allData,aes(x=x,y=y,colour=factor(condition),
alpha=as.numeric(condition)))+
geom_point()+
scale_alpha_continuous(legend=FALSE)+
scale_colour_manual(value=c("black","red"))
> <mailto:ggp...@googlegroups.com>
> To unsubscribe: email ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>
> More options: http://groups.google.com/group/ggplot2
>
>
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1daYgACgkQc5UpGjwzenOhugCfVVxH5YmfsT5pNAcEyEmkpIT2
QQwAn2ZUViZITbaxcikl85KKVIqxHy9E
=xzxq
-----END PGP SIGNATURE-----
| McCreight <mccr...@gmail.com>
Sent by: ggp...@googlegroups.com 02/17/2011 03:35 PM |
|
On 02/17/2011 04:25 PM, Adam_L...@KeyBank.com wrote:
>
> Thanks very much! That did the trick.
>
> One more quick question - is there a function that translates between
> hexadecimal representations of colors and the english names?
>
plotrix::color.id
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1dk9IACgkQc5UpGjwzenPWbgCfcAIvwWIZFBb9DnA+UZrldtHu
Hb8An0jJ14IoqDH6hthSmNkwUt17tnMd
=lQAo
-----END PGP SIGNATURE-----