0

Here is the example of overlaying of barplots

library(data.table)
library(ggplot2)
set.seed(100)
dat <- data.frame(Axis=letters[1:10],V1=1:10, V2=runif(10, 1,10), V3=10:1)

ggplot(dat, aes(x = Axis)) + theme_classic() + 
  geom_col(aes(y = V1), fill = "darkred", alpha = .5) + 
  geom_col(aes(y = V2), fill = "blue", alpha = .5, 
           position = position_nudge(x = 0.2)) 

enter image description here

I want to only get the smoothed coutours and shading below so thta it looks like this example below. How can I do that for a discreete x-axis?

enter image description here

RPlotter
  • 109
  • 1
  • 2
  • 11
  • 1
    Can you elaborate a little more? Are you saying you want to do a density plot? Or you want your bar plot to look like a density plot in some way? If so, in what way exactly? – SamR Jul 13 '22 at 14:05
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. It seems very misleading to have smooth curves across discrete x categories. – MrFlick Jul 13 '22 at 14:09
  • @SamR I want to join the means of my bar plot with a line. Then I want everything below that line shaded in the color corresponding V1 and V2 with appropriate transparency (alpha) so that I can see both of them. Does that help? – RPlotter Jul 13 '22 at 15:12
  • @MrFlick I want to join the means of my bar plot with a line. Then I want everything below that line shaded in the color corresponding V1 and V2 with appropriate transparency (alpha) so that I can see both of them. Does that help? – RPlotter Jul 13 '22 at 15:13

0 Answers0