【发布时间】:2018-10-15 16:10:10
【问题描述】:
我正在尝试将图形附加在背景蛋白质骨架上(使用 geom_rect() 函数绘图)。有什么方法可以创建圆边矩形而不是基本矩形(特别是红色矩形)。 这是我使用的代码。
我尝试了 grid 的 roundrectGrob() 函数,但收到错误 Error: Don't know how to add roundrectGrob(x = 28, y = -2.3, width = 22, height = 0.45) to a plot
library(ggplot2)
p <- ggplot() +
ylim(-4, 4) +
xlim(0, 100)
## First rect
p <- p + geom_rect(mapping=aes(xmin=10,
xmax=90,
ymin=-2.15,
ymax=-2.00),
colour = "black",
fill = "grey")
## Second rect
p <- p + geom_rect(mapping=aes(xmin=28,
xmax=50,
ymin=-2.30,
ymax=-1.85),
colour = "black",
fill = "red")
# print
p
dev.off()
【问题讨论】:
-
已经试过了。但是得到了这个错误。 p + geom_rrect(mapping=aes(xmin=28, + xmax=50, + ymin=-2.30, + ymax=-1.85), + color = "black", + fill = "red") geom_rrect 中的错误(mapping = aes(xmin = 28, xmax = 50, ymin = -2.3, ymax = -1.85), : 找不到函数“geom_rrect”。
-
我(懒惰地)暗示你可以将源代码复制到你的会话中???