r - ggplot:有没有更简洁的方式使用主题背景?
问题描述
我想包括一些充满背景的圆圈,以便它们覆盖下面的任何东西,但仍然融入背景。
在下面的示例中,我以编程方式使用hrbrthemes::theme_ft_rc()$plot.background$fill
. 但是,我想知道是否有更清洁、更短的方法。黑色背景的圆圈只是为了显示我不想要的东西:)
library(ggplot)
x = c(0,1)
y = c(0,3)
xend = c(4,2)
yend = c(4,2)
data = data.frame(x, xend, y, yend)
p2 <- ggplot(data) +
geom_link(aes(x = x, xend = xend, y = y, yend = yend)) +
# Starting circle
geom_point(aes(x = x, y = y), size=5, shape = 21, alpha=1,
fill = "black"
) +
# Ending circle
geom_point(aes(x = xend, y = yend), size=5, shape = 21, alpha=1,
fill = hrbrthemes::theme_ft_rc()$plot.background$fill
) +
hrbrthemes::theme_ft_rc()
p2
解决方案
推荐阅读
- bootstrap-4 - 导航栏切换按钮在点击时右移和上移 30px
- typescript - 为什么不推荐使用 typeRoots 来指定 d.ts 文件的位置?
- node.js - 在 node.js 项目中抓取 ldJSON
- meshlab - 如何使用 PyMeshLab 将顶点数减少到一定数量
- facebook - Facebook登录返回账号基本信息
- flutter - Flutter 谷歌日历每次都要求 Oauth 同意
- node.js - 如何使用 node.js 解码和验证 AWS SigV4 请求的签名
- reactjs - 为什么我收到 400 bad request 错误?使用 Django Rest 框架作为后端并使用 React 作为我的 Web 应用程序的前端
- javascript - 如何计算相对百分比?
- azure-devops - 如何在 Azure DevOps 中设置 CI 以使其使用不同的环境应用程序设置?