Reputation: 1384
I have a trouble about the legend of shape in R.
I used ggplot to draw a graph like this:
ggplot(data,aes(x=ex1score,y=ex2score,shape=m_shape,color=m_shape))+
geom_point()
But I want to change:
m_shape --> result
0--> fail
1-->pass
Please help me to solve this problem.
Thank a lot
Upvotes: 1
Views: 4093
Reputation: 4761
You could do:
ggplot(data,aes(x=ex1score,y=ex2score,shape=m_shape,color=m_shape))+
geom_point()+
scale_color_discrete(labels=c("fail","pass"),name="result")+
scale_shape_discrete(labels=c("fail","pass"),name="result")
I don't think you can get away with only specifying the labels and name once since m_shape
affects both shape and color
Upvotes: 4