Reputation: 85
I'm trying to change the legend in my figure and I've never had this much trouble before. I want 1) no title & 2) instead of the variable values "s1, s2, s3" I want "serotype 1,2,3".
I know i can just relabel the factor but I don't want to do that because I'm stubborn also I don't like having spaces in my variable values
why isn't scale_shape_manual working?
ggplot()+
geom_point(data=seromelt, aes(x=X, y=value, color=variable, group=variable),
stat= 'identity', size=2, position=position_dodge(width =.2)) +
geom_errorbar(data=tbl1, aes(x=X, y=value, color=variable, ymin=value-se, ymax= value+se),
width= 0, size=1, position=position_dodge(width =.2)) +
ylab("Percent") +
scale_y_continuous(breaks=seq(0,100,10)) +
xlab("Health Zone") +
scale_shape_manual(name="",
breaks= c("s1", "s2", "s3"),
labels= c("Serotype 1", "Serotype 2", "Serotype 3")) +
theme_bw() +
theme(panel.grid.major.y = element_blank(),
axis.text.x = element_text(size=12),
axis.text.y = element_text(size=12),
legend.text =element_text(size=12)) +
coord_flip()
current outcome:
Upvotes: 1
Views: 82
Reputation: 466
It needs to be scale_colour_discrete. Try this:
{the rest of ggplot} + scale_colour_discrete(name = "",
breaks=c("s1", "s2", "s3"),
labels=c("Serotype 1", "Serotype 2", "Serotype 3"))
Upvotes: 1