啊啊啊啊啊吖

2019-02-20   阅读量: 3508

数据分析师 R语言

如何删除添加到图例的倾斜线?

扫码加入数据分析学习群



如何删除添加到图例的倾斜线?还有黄色和灰色的点......它为什么会发生?
library(ggplot2) x <- seq(from = 1, to = 10, by = 1) df = data.frame(x=x, y=x^2, v=2*x) df2 = data.frame(x=x, y=x^2-5*x-10) ggplot(df, aes(x, y)) + geom_point(aes(size = v)) + theme_classic() + scale_size("blabla") + geom_point(data=df2, aes(x, y, color = "blue")) + geom_line(data=df2, aes(x, y, color = "blue")) + geom_hline(aes(color="gray",yintercept=25)) + geom_abline(aes(color="yellow", intercept=0, slope=1)) + scale_color_manual(values = c("blue","gray","yellow"), labels = c("nanana","hhh","abab"), name = "other")

在此输入图像描述

添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 4 关注作者 收藏

评论(1)

啊啊啊啊啊吖
2019-02-20

geom_pointgeom_linegeom_hline,和geom_abline。为了摆脱这些界限,我们需要

geom_abline(aes(color = "yellow", intercept = 0, slope = 1), show.legend = FALSE)

而对于我们必须添加的点

guides(color = guide_legend(override.aes = list(shape = c(19, NA, NA))))

在此输入图像描述

0.0000 0 0 回复

推荐课程