r - Define (not use default) for shapes in ggplot -



r - Define (not use default) for shapes in ggplot -

i trying create scatterplot 3 shapes (small circle, big circle, , cross).

i able point have want, except can't figure out how specify shapes:

adata=as.data.frame(cbind(x=rnorm(5, 10, 1),y=rnorm(5,10,1))) adata["type"] = rep(1,dim(adata)[1]) bdata=as.data.frame(cbind(x=rnorm(5, 20, 1),y=rnorm(5,20,1))) bdata["type"] = rep(2,dim(bdata)[1]) cdata=as.data.frame(t(c(0,0,3))) colnames(adata) = c("ankle.dif", "knee.dif", "type") colnames(bdata) = c("ankle.dif", "knee.dif", "type") colnames(cdata) = c("ankle.dif", "knee.dif", "type") dataframeplot = rbind(adata, bdata, cdata) ggplot(dataframeplot, aes(x=ankle.dif, y=knee.dif)) + geom_point(aes(shape = factor(type)))

i circle, triangle, , square here, prefer specify little circle, big circle, , crossbar 3 types. ideas? thanks!

here 1 way using scale_shape_manual. shape, can find more info in many places. here link you. op requested in comment below, modified legend.

ggplot(dataframeplot, aes(x=ankle.dif, y=knee.dif)) + geom_point(aes(shape = factor(type)))+ scale_shape_manual(name = "data", values=c(20, 19, 3), breaks=c("1", "2", "3"), labels=c("first data", "second data", "third data"))

r ggplot2 shapes

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -