use*_*745 4 r ggplot2 geom-curve
我似乎无法使箭头变成凹形。angle我对其中的论点进行了多次调整geom_curve
library(ggplot2)
library(dplyr)
set.seed(123)
data.frame(x = runif(200)* 1000, y = runif(200)* 1000) %>%
ggplot(aes(x, y)) +
geom_point() +
geom_curve(
aes(x = 200, y = 300, xend = 500, yend = 400),
arrow = arrow(length = unit(0.03, "npc"), type="closed"), colour = "#EC7014", size = 1.2, angle = 90)
Run Code Online (Sandbox Code Playgroud)
上面的箭头是凸的 - 目标是使箭头呈彩虹形状(凹)。我已经改变了angle起点/终点,但所有生成的箭头仍然是凸形的
这里的箭头指向条形的粉红色部分 - 底部的箭头看起来不错,但如果可以将顶部的箭头做成凹面,看起来会更好
我想你想要curvature参数。正值具有逆时针卷曲,负值具有顺时针卷曲。这是一个代表:
library(ggplot2)
ggplot() +
geom_text(aes(x = -5, y = 5, label = "Some text"), size = 10, hjust = 0) +
geom_rect(aes(xmin = 0, xmax = 5, ymin = 2.5, ymax = 7.5)) +
geom_curve(aes(x = -2.5, y = 5.5, xend = -1.25, yend = 6),
arrow = arrow(length = unit(0.03, "npc"), type="closed"),
colour = "#EC7014", size = 1.2, curvature = -0.3, angle = 90) +
geom_curve(aes(x = -2.5, y = 4.5, xend = -1.25, yend = 4),
arrow = arrow(length = unit(0.03, "npc"), type="closed"),
colour = "#EC7014", size = 1.2, curvature = 0.3, angle = 90)
Run Code Online (Sandbox Code Playgroud)

由reprex 包(v0.3.0)于 2020-05-09 创建