geom_curve with variable linewidth

103 views Asked by At

Thanks to @jared_mamrot, proposes gg_arrow. Now I need to combine gem_curve with gg_arrow.

Here is a sample code of gg_arrow:

install.packages("devtools")
devtools::install_github("teunbrand/ggarrow")

library(ggarrow)
library(ggplot2)

p <- ggplot(whirlpool(5), aes(x, y, colour = group)) +
  coord_equal() +
  guides(colour = "none")

p + geom_arrow(aes(linewidth = I(arc))) # Identity scale for linewidth

It requires "arc" to identify the width.

If I draw something like this:

df <- data.frame(x1 = 120, x2 = 120, y1 = 40, y2 = 35)


ggplot() + 
  geom_curve(data = df, aes(x = x1, y = y1, xend = x2, yend = y2), curvature = -0.2, arrow = arrow(length = unit(0.05, "npc"))) 

enter image description here

I don't have the arc, seems I need to create the arc before I draw the curve. Is there a way extracting arc after doing geom_curve?


enter image description here

Is this possible in R? Arrows with lines showing routes.

geom_segment cannot draw arrows with different width (from thick to thin)

I saw people asking this here https://community.plotly.com/t/arrows-instead-of-simple-lines-on-a-map/2775, plotly doesn't seems to work.

0

There are 0 answers