I have a dataset with odds ratios and Confidence interval of each odds ratio, plotted with errorbars. I have included a shaded area to indicate the variation of confidence intervals as follows
set.seed(10)
y <- runif(18, 0, 5) # Odds ratios
spread <- runif(18, 0, 2) # Confidence intervals
CI_hi <- y + spread/2 # The upper level of CIs
CI_lo <- y - spread/2 # Lower level of CIs
x <- seq(from=0.3, to=2.0, by=0.1) # x-values
library(ggplot2)
ggplot(data = NULL, aes(x=x, y=y)) +
geom_point(shape=18, color="deepskyblue3") +
geom_errorbar(aes(ymin=CI_lo, ymax=CI_hi), width=.0, color="deepskyblue3") +
geom_hline(yintercept = 1, color="darkgrey") +
theme(
axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1),
panel.background = element_blank(),
axis.ticks.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(size = 0.25, linetype = 'solid', colour = "grey"),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
text=element_text(family="Georgia", size=12)
) +
geom_polygon(aes(x=append(x,rev(x)), y=append(CI_hi,rev(CI_lo))), alpha=0.2) +
ylab("Odds ratio") +
xlab("Some variable")
Is there a way to smoothen the edges of the shaded area?