Is there a way to introduce the arguments "density" and "angle", or any other interesting ones from "ggplot::barplot" into "ggplot::geom_ribbon"?
I have been looking for basic texture of geom_ribbon -like points and crosses and lines-, instead of only "fill"-ing them with variable colors. I saw the package ggtexture, but it uses .svg external files, and does include barplotting, but not ribbons similar to geom_ribbons, apparently. The most promising was the barplots I saw here: Barplots example with texture. I mean, according to the description, geom_ribbon is close to the drawing of barplots, as if they were areas of y height.
I, however, don't understand how to modify source code myself.
You could try the (non-CRAN) package ggpattern
, as demonstrated in Ian Campbell's recent question and answer
Here's a demo using a geom_ribbon_pattern
:
remotes::install_github("coolbutuseless/ggpattern")
library(ggpattern)
x <- seq(pi/2, 20, 0.1)
df <- data.frame(x, lower = 10 * (cos(x)/x - .3), upper = (10 * -cos(x)/x + .3))
ggplot(df) +
geom_ribbon_pattern(aes(x, ymin = lower, ymax = upper), fill = "gray95",
color = "black",
pattern = "stripe",
pattern_fill = "gray80",
pattern_angle = 45,
pattern_density = 0.2,
pattern_spacing = 0.05) +
coord_equal() +
theme_classic()