【发布时间】:2015-04-16 09:46:37
【问题描述】:
我对使用 ggplot 包比较陌生。我想使用名称“Sp1”和“Sp2”重命名绘图的图例。我尝试使用以下代码来实现它,但我无法做到。
这是代码:
t<-read.table ("covartimesfinal2.txt", header=T)
attach(t)
p <- ggplot(t,aes(x=Ratio,y=Time)) + geom_point(aes(shape=factor(Sp)))
p + geom_smooth(aes(linetype=factor(Sp), ),colour="black", method='lm',
se=F)+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),panel.background = element_blank(), axis.line =
element_line(colour = "black"))+
scale_shape_discrete(name ="Species",labels=c("Sp1", "Sp2"))
我的目标是摆脱名为“因子(Sp)”的图例,并使轴的数字变为黑色而不是灰色。
提前致谢!请找到附上的示例图
【问题讨论】:
-
欢迎来到 SO!您的任务看起来很简单,但如果您想要一个完整的解决方案,请通过添加您的数据的最小样本来创建 reproducible example。
-
能否提供给我们(部分)covartimesfinal2.txt?
-
对不起!这是我的第一篇文章。有没有办法上传txt文件?
标签: r ggplot2 legend legend-properties