Varying thickness for a line between 2 points

Is there any way to have a varying thickness for a line between 2 points using ggplot?. For example there are 2 points A(Starting point) and B(end point). The line between 2 points should have a varying thickness like at the starting it should be thin and gradually the thickness should increase and reach max when it's near B.

What about geom_ribbon():


tibble(x = c(1,2),
           y = c(30,40),
           width = c(1,2)) |>
  mutate(ymin = y -width,
         ymax = y + width) |>
  ggplot() +
  geom_ribbon(aes(x = x, ymin = ymin, ymax = ymax),
              fill = 'grey40')

Created on 2023-05-07 with reprex v2.0.2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.