r - 避免传说中的彩色框
问题描述
如何避免传说中的彩色框?我只是希望它Line1
没有Line2
盒子。
library(ggplot2)
ggplot(diamonds, aes(x=depth)) +
geom_density(aes(color = "Line1"))+
geom_function(fun=function(x)
dnorm(x,
mean=mean(diamonds$depth),
sd=sd(diamonds$depth)),
aes(color="Line2"))+
scale_color_manual(" ", values=c(Line1="green", Line2="red"))
谢谢!
解决方案
这可以通过添加选项show.legend = FALSE
来实现geom_density
:
library(ggplot2)
ggplot(diamonds, aes(x=depth)) +
geom_density(aes(color = "Line1"), show.legend = FALSE)+
geom_function(fun=function(x)
dnorm(x,
mean=mean(diamonds$depth),
sd=sd(diamonds$depth)),
aes(color="Line2"))+
scale_color_manual(" ", values=c(Line1="green", Line2="red"))
推荐阅读
- java - 注入作为单例和 jax-rs 中的请求类
- isapi - GET 请求时的海康威视错误 /ISAPI/System/status
- python - 如何从随机打乱的像素中再现图像?
- sql - SQL query for entries of last N jobs
- node.js - 如何在 Microsoft Teams Bot - NodeJS 中调用父对话框?
- javascript - 谷歌浏览器 STATUS_ACCESS_VIOLATION 错误
- azure-data-factory-2 - 如何在不嵌套 if 活动的情况下根据某些条件执行多个 ADF 管道?
- contacts - 通过 APi 创建的联系人未显示在 Xero 应用程序中
- python - 有人可以解释我如何访问我列表中的名字吗?无论您使用哪种方法。基维,蟒蛇
- python - 有没有办法同时优化时间和路径?