AckerDWM / gg3D

A ggplot2 extension enabling 3D projections
103 stars 11 forks source link

Issue with order of point plotting layers #3

Closed MVesuviusC closed 3 years ago

MVesuviusC commented 5 years ago

Hello, I'm not sure if this is an issue with your package or a factor of how ggplot2 works, but if I plot data in 3-dimensional space, sometimes points that are behind others are plotted in front. I noticed this when I was trying to create a bunch of 3d plots and combine them into a gif. Example code and an output gif are included to show how this results in some really weird behavior. Note how the red points are always behind all the other points.

Thanks for taking the time to create and publish your software!

for(i in 1:360) { 
  png(paste("gif/Iris", formatC(i, width = 3, flag = "0"), "_3d.png", sep = ""), 
      width = 1000, 
      height = 1000, 
      res = 200)

  print(
    ggplot(data = iris, aes(x=Petal.Width, 
                            y=Sepal.Width, 
                            z=Petal.Length, 
                            color=Species)) +
      axes_3D(theta = 90, 
              phi = i) +
      stat_3D(theta = 90, 
              phi = i, 
              size = 8) +
      theme_void()
  )
  dev.off()
}

# run on unix command line: 

convert -loop 0 -delay 1 gif/Iris*.png test2.gif

test2

AckerDWM commented 5 years ago

I think that has to do with the order in which groups are drawn in ggplot. I've used this package for exploratory viz, but plotly has nicer 3d capabilities for professional looking plots.

On Mon, Mar 25, 2019 at 10:48 AM Matt Cannon notifications@github.com wrote:

Hello, I'm not sure if this is an issue with your package or a factor of how ggplot2 works, but if I plot data in 3-dimensional space, sometimes points that are behind others are plotted in front. I noticed this when I was trying to create a bunch of 3d plots and combine them into a gif. Example code and an output gif are included to show how this results in some really weird behavior. Note how the red points are always behind all the other points.

Thanks for taking the time to create and publish your software!

for(i in 1:360) { png(paste("gif/Iris", formatC(i, width = 3, flag = "0"), "_3d.png", sep = ""), width = 1000, height = 1000, res = 200)

print( ggplot(data = iris, aes(x=Petal.Width, y=Sepal.Width, z=Petal.Length, color=Species)) + axes_3D(theta = 90, phi = i) + stat_3D(theta = 90, phi = i, size = 8) + theme_void() ) dev.off() }

run on unix command line:

convert -loop 0 -delay 1 gif/Iris*.png test2.gif

[image: test2] https://user-images.githubusercontent.com/5831817/54928857-fcacaf00-4eea-11e9-87c3-f5cf61e1b95c.gif

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AckerDWM/gg3D/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ANCP7vbpvzuEt6OvK64WyDjI3j5ySsBdks5vaOHNgaJpZM4cHEkR .

-- Daniel Acker, PhD

MVesuviusC commented 5 years ago

Thanks for the reply. I ended up using the lattice cloud() function to make the plot.