r - ggplot绘图区域顶部和底部的线条
问题描述
我想在使用 ggplot2 创建的图的顶部和底部添加一条线(x 标签和轴下方的底线)。到目前为止,我已经在绘图周围添加了一个矩形,但我不希望两边有线条。
x <- 1:10
y <- rnorm(10,mean = x)
df <- data.frame(x,y)
library(ggplot2)
ggplot(data = df, mapping = aes(x,y)) + geom_point() +
theme(plot.background = element_rect(size = 1, color = 'blue'))
我希望你们有一个解决方案。
解决方案
类似的东西会起作用吗?
x <- 1:10
y <- rnorm(10,mean = x)
df <- data.frame(x,y)
ggplot(data = df, mapping = aes(x,y)) + geom_point() +
annotate(geom = 'segment',
y = Inf,
yend = Inf,
x = -Inf,
xend = Inf,
size = 2) +
theme(axis.line.x = element_line(size = 1))
推荐阅读
- javascript - 带有复选框的 Javascript localStorage 联系人
- javascript - Javascript 项目出现空错误。(空==0?!)
- javascript - 为什么这个 Javascript 函数没有打印到我的 HTML 文档中?
- c++ - invoke_result_t<> 没有将 lambda 与引用参数匹配
- python - 使用 PyGaze 时没有名为“psychopy”的模块
- google-app-engine - 如何使用删除方法从谷歌数据存储以及我的 html 页面中删除元素?
- swift - 泛型函数参数的多重约束
- javascript - 为什么 offsetTop 在 Chrome 和 IE 中返回不同的值
- r - 使用R将某些行的值总和到一个新列中
- java - 如何修复java数组首先在for循环中跳过第一个用户输入