title: Plot 3D data in R
body: <p>I have a 3D dataset:</p>
  
  <pre><code>data = data.frame(
      x = rep( c(0.1, 0.2, 0.3, 0.4, 0.5), each=5),
      y = rep( c(1, 2, 3, 4, 5), 5)
  )
  
  data$z = runif(
      25,
      min = (data$x*data$y - 0.1 * (data$x*data$y)),
      max = (data$x*data$y + 0.1 * (data$x*data$y))
  )
  
  data
  str(data)
  </code></pre>
  
  <p>And I want to plot it, but the built-in-functions of R alwyas give the error </p>
  
  <blockquote>
    <p>increasing 'x' and 'y' values expected</p>
  </blockquote>
  
  <pre><code># ### 3D Plots ######################################################
  # built-in function always give the error
  #    "increasing 'x' and 'y' values expected"
  demo(image)
  image(x = data$x, y = data$y, z = data$z)
  
  demo(persp)
  persp(data$x,data$y,data$z)
  
  contour(data$x,data$y,data$z)
  </code></pre>
  
  <p>When I searched on the internet, I found that this message happens when combinations of X and Y values are not unique. But here they are unique.</p>
  
  <p>I tried some other libraries and there it works without problems. But I don't like the default style of the plots (the built-in functions should fulfill my expectations).</p>
  
  <pre><code># ### 3D Scatterplot ######################################################
  # Nice plots without surface maps?
  install.packages("scatterplot3d", dependencies = TRUE)
  library(scatterplot3d)
  scatterplot3d(x = data$x, y = data$y, z = data$z)
  
  # ### 3D Scatterplot ######################################################
  # Only to play around?
  install.packages("rgl", dependencies = TRUE)
  library(rgl)
  plot3d(x = data$x, y = data$y, z = data$z)
  lines3d(x = data$x, y = data$y, z = data$z)
  surface3d(x = data$x, y = data$y, z = data$z)
  </code></pre>
  
  <p>Why are my datasets not accepted by the built-in functions?</p>