0

I have a ggplot of three trajectories (unique values in the variable column is three) with confidence intervals.

This is my plot:

ggplot(df, aes(x=time, y=value, group=variable, color=variable, stroke=1.5))+ 
  
  geom_rect(aes(xmin = -Inf,xmax = 7,ymin = -Inf, ymax = Inf),
            fill="#DAEAF1", 
            alpha = .2)+
  geom_vline(xintercept=7)+
  stat_summary(geom="ribbon", fun.data=mean_cl_normal, width=0.1, conf.int=0.95)+
  stat_summary(geom="line", fun.y=mean, linetype="dashed")+
  stat_summary(geom="point", fun.y=mean, shape=8, size=1)
  

and the head of df is:

X time    variable     value
1 1 0.00 M 0.1507799
2 2 0.33 M 0.1254237
3 3 1.00 M 0.3680203
4 4 3.00 M 0.6286472
5 5 7.00 M 0.7751938
6 6 7.33 M 0.7857143

Now suppose I have multiple of dfs --> df1, df2, df3 and I want to show these ggplots stacked in a 3d plot. How can I do that in R? I want something like this link but with ggplot so it looks nicer--> How can I make 3d plot with stacked 2d plot?

A4747
  • 85
  • 8
  • 1
    ggplot doesn't lend itself well to 3D plots (in fact 3D plots are kind of against the ethos of ggplot) It's not impossible, but it would be a lot of effort and unlikely to generate a satisfactory result. You could look at the [gg3d](https://github.com/AckerDWM/gg3D) package, but it hasn't been updated in 5 years – Allan Cameron Oct 17 '22 at 19:34
  • 1
    If you're open to experimental packages, you could give [{ggrgl}](https://coolbutuseless.github.io/package/ggrgl/) a go. – teunbrand Oct 17 '22 at 19:35

0 Answers0