How to plot a surface in rgl plot3d












1














So I have this code that produces the exact surface



f = function(x, y){
z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
}
plot3d(f, col = colorRampPalette(c("blue", "white")),
xlab = "X", ylab = "Y", zlab = "Z",
xlim = c(-3, 3), ylim = c(-3, 3),
aspect = c(1, 1, 0.5))


Giving the following plot:
3d exact plot
Now I have some code that does a random walk metropolis algorithm to reproduce the above image. I think it works as if I do another plot of these calculated values I get the next image with 500 points. Here is the code



open3d()
plot3d(x0, y0, f(x0, y0), type = "p")


Which gives the following plot:
enter image description here
I know it's hard looking at this still image but being able to rotate the sampling is working.



Now here is my question: How can I use plot3d() so that I can have a surface that connects all these points and gives a more jagged representation of the exact plot? Or how can I have each point in the z axis as a bar from the xy plane? I just want something more 3 dimensional than points and I can't find how to do this.



Thanks for your help










share|improve this question





























    1














    So I have this code that produces the exact surface



    f = function(x, y){
    z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
    }
    plot3d(f, col = colorRampPalette(c("blue", "white")),
    xlab = "X", ylab = "Y", zlab = "Z",
    xlim = c(-3, 3), ylim = c(-3, 3),
    aspect = c(1, 1, 0.5))


    Giving the following plot:
    3d exact plot
    Now I have some code that does a random walk metropolis algorithm to reproduce the above image. I think it works as if I do another plot of these calculated values I get the next image with 500 points. Here is the code



    open3d()
    plot3d(x0, y0, f(x0, y0), type = "p")


    Which gives the following plot:
    enter image description here
    I know it's hard looking at this still image but being able to rotate the sampling is working.



    Now here is my question: How can I use plot3d() so that I can have a surface that connects all these points and gives a more jagged representation of the exact plot? Or how can I have each point in the z axis as a bar from the xy plane? I just want something more 3 dimensional than points and I can't find how to do this.



    Thanks for your help










    share|improve this question



























      1












      1








      1







      So I have this code that produces the exact surface



      f = function(x, y){
      z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
      }
      plot3d(f, col = colorRampPalette(c("blue", "white")),
      xlab = "X", ylab = "Y", zlab = "Z",
      xlim = c(-3, 3), ylim = c(-3, 3),
      aspect = c(1, 1, 0.5))


      Giving the following plot:
      3d exact plot
      Now I have some code that does a random walk metropolis algorithm to reproduce the above image. I think it works as if I do another plot of these calculated values I get the next image with 500 points. Here is the code



      open3d()
      plot3d(x0, y0, f(x0, y0), type = "p")


      Which gives the following plot:
      enter image description here
      I know it's hard looking at this still image but being able to rotate the sampling is working.



      Now here is my question: How can I use plot3d() so that I can have a surface that connects all these points and gives a more jagged representation of the exact plot? Or how can I have each point in the z axis as a bar from the xy plane? I just want something more 3 dimensional than points and I can't find how to do this.



      Thanks for your help










      share|improve this question















      So I have this code that produces the exact surface



      f = function(x, y){
      z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
      }
      plot3d(f, col = colorRampPalette(c("blue", "white")),
      xlab = "X", ylab = "Y", zlab = "Z",
      xlim = c(-3, 3), ylim = c(-3, 3),
      aspect = c(1, 1, 0.5))


      Giving the following plot:
      3d exact plot
      Now I have some code that does a random walk metropolis algorithm to reproduce the above image. I think it works as if I do another plot of these calculated values I get the next image with 500 points. Here is the code



      open3d()
      plot3d(x0, y0, f(x0, y0), type = "p")


      Which gives the following plot:
      enter image description here
      I know it's hard looking at this still image but being able to rotate the sampling is working.



      Now here is my question: How can I use plot3d() so that I can have a surface that connects all these points and gives a more jagged representation of the exact plot? Or how can I have each point in the z axis as a bar from the xy plane? I just want something more 3 dimensional than points and I can't find how to do this.



      Thanks for your help







      r rgl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 16:08









      camille

      6,82131327




      6,82131327










      asked Nov 20 at 17:10









      MRT

      19516




      19516
























          3 Answers
          3






          active

          oldest

          votes


















          2














          You can do this by triangulating the surface. You don't give us your actual data, but I can create some similar data using



          f = function(x, y){
          z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
          }
          x <- runif(500, -3, 3)
          y <- runif(500, -3, 3)
          z <- f(x, y)


          Then the plotting is done using the method in ?persp3d.deldir:



          library(deldir)
          library(rgl)
          col <- colorRampPalette(c("blue", "white"))(20)[1 + round(19*(z - min(z))/diff(range(z)))]
          dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
          persp3d(dxyz, col = col, front = "lines", back = "lines")


          This might need some cosmetic fixes, e.g.



          aspect3d(2, 2, 1)


          After some rotation, this gives me the following plot:



          enter image description here






          share|improve this answer





















          • I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
            – MRT
            Dec 1 at 17:00



















          0














          I'm not sure to understand what you want. If my understanding is correct, here is a solution. Define a parametric representation of your surface:



          fx <- function(u,v) u
          fy <- function(u,v) v
          fz <- function(u,v){
          ((u^2)+(3*v^2))*exp(-(u^2)-(v^2))
          }


          Let's say you have these points:



          x0 <- seq(-3, 3, length.out = 20)
          y0 <- seq(-3, 3, length.out = 20)


          Then you can use the function parametric3d of the misc3d package, with the option fill=FALSE to get a wireframe:



          library(misc3d)
          parametric3d(fx, fy, fz, u=x0, v=y0,
          color="blue", fill = FALSE)


          enter image description here



          Is it what you want?



          To get some vertical bars, use the function segments3d of rgl:



          i <- 8
          bar <- rbind(c(x0[i],y0[i],0),c(x0[i],y0[i],f(x0[i],y0[i])))
          segments3d(bar, color="red")





          share|improve this answer























          • Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
            – Stéphane Laurent
            Nov 21 at 16:02












          • Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
            – MRT
            Nov 23 at 10:16












          • @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
            – Stéphane Laurent
            Nov 23 at 10:58










          • True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
            – MRT
            Nov 25 at 16:37










          • Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
            – MRT
            Nov 25 at 16:46



















          0














          Here is a plot with only 50 points using my original code.



          Scatter graph of 50 points



          When I then apply what was said by Stéphane Laurent I then get this plot which feels too accurate when given the actual points I have



          wire plot



          Perhaps you need to explain to me what is actually happening in the function parametric3d






          share|improve this answer

















          • 1




            I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
            – Stéphane Laurent
            Nov 28 at 7:31











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398108%2fhow-to-plot-a-surface-in-rgl-plot3d%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You can do this by triangulating the surface. You don't give us your actual data, but I can create some similar data using



          f = function(x, y){
          z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
          }
          x <- runif(500, -3, 3)
          y <- runif(500, -3, 3)
          z <- f(x, y)


          Then the plotting is done using the method in ?persp3d.deldir:



          library(deldir)
          library(rgl)
          col <- colorRampPalette(c("blue", "white"))(20)[1 + round(19*(z - min(z))/diff(range(z)))]
          dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
          persp3d(dxyz, col = col, front = "lines", back = "lines")


          This might need some cosmetic fixes, e.g.



          aspect3d(2, 2, 1)


          After some rotation, this gives me the following plot:



          enter image description here






          share|improve this answer





















          • I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
            – MRT
            Dec 1 at 17:00
















          2














          You can do this by triangulating the surface. You don't give us your actual data, but I can create some similar data using



          f = function(x, y){
          z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
          }
          x <- runif(500, -3, 3)
          y <- runif(500, -3, 3)
          z <- f(x, y)


          Then the plotting is done using the method in ?persp3d.deldir:



          library(deldir)
          library(rgl)
          col <- colorRampPalette(c("blue", "white"))(20)[1 + round(19*(z - min(z))/diff(range(z)))]
          dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
          persp3d(dxyz, col = col, front = "lines", back = "lines")


          This might need some cosmetic fixes, e.g.



          aspect3d(2, 2, 1)


          After some rotation, this gives me the following plot:



          enter image description here






          share|improve this answer





















          • I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
            – MRT
            Dec 1 at 17:00














          2












          2








          2






          You can do this by triangulating the surface. You don't give us your actual data, but I can create some similar data using



          f = function(x, y){
          z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
          }
          x <- runif(500, -3, 3)
          y <- runif(500, -3, 3)
          z <- f(x, y)


          Then the plotting is done using the method in ?persp3d.deldir:



          library(deldir)
          library(rgl)
          col <- colorRampPalette(c("blue", "white"))(20)[1 + round(19*(z - min(z))/diff(range(z)))]
          dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
          persp3d(dxyz, col = col, front = "lines", back = "lines")


          This might need some cosmetic fixes, e.g.



          aspect3d(2, 2, 1)


          After some rotation, this gives me the following plot:



          enter image description here






          share|improve this answer












          You can do this by triangulating the surface. You don't give us your actual data, but I can create some similar data using



          f = function(x, y){
          z = ((x^2)+(3*y^2))*exp(-(x^2)-(y^2))
          }
          x <- runif(500, -3, 3)
          y <- runif(500, -3, 3)
          z <- f(x, y)


          Then the plotting is done using the method in ?persp3d.deldir:



          library(deldir)
          library(rgl)
          col <- colorRampPalette(c("blue", "white"))(20)[1 + round(19*(z - min(z))/diff(range(z)))]
          dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
          persp3d(dxyz, col = col, front = "lines", back = "lines")


          This might need some cosmetic fixes, e.g.



          aspect3d(2, 2, 1)


          After some rotation, this gives me the following plot:



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 at 16:34









          user2554330

          8,85311237




          8,85311237












          • I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
            – MRT
            Dec 1 at 17:00


















          • I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
            – MRT
            Dec 1 at 17:00
















          I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
          – MRT
          Dec 1 at 17:00




          I think this gives the closest thing to what I was looking for and there is no extra points being added to the data as with the other answers so this is very nice thank you
          – MRT
          Dec 1 at 17:00













          0














          I'm not sure to understand what you want. If my understanding is correct, here is a solution. Define a parametric representation of your surface:



          fx <- function(u,v) u
          fy <- function(u,v) v
          fz <- function(u,v){
          ((u^2)+(3*v^2))*exp(-(u^2)-(v^2))
          }


          Let's say you have these points:



          x0 <- seq(-3, 3, length.out = 20)
          y0 <- seq(-3, 3, length.out = 20)


          Then you can use the function parametric3d of the misc3d package, with the option fill=FALSE to get a wireframe:



          library(misc3d)
          parametric3d(fx, fy, fz, u=x0, v=y0,
          color="blue", fill = FALSE)


          enter image description here



          Is it what you want?



          To get some vertical bars, use the function segments3d of rgl:



          i <- 8
          bar <- rbind(c(x0[i],y0[i],0),c(x0[i],y0[i],f(x0[i],y0[i])))
          segments3d(bar, color="red")





          share|improve this answer























          • Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
            – Stéphane Laurent
            Nov 21 at 16:02












          • Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
            – MRT
            Nov 23 at 10:16












          • @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
            – Stéphane Laurent
            Nov 23 at 10:58










          • True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
            – MRT
            Nov 25 at 16:37










          • Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
            – MRT
            Nov 25 at 16:46
















          0














          I'm not sure to understand what you want. If my understanding is correct, here is a solution. Define a parametric representation of your surface:



          fx <- function(u,v) u
          fy <- function(u,v) v
          fz <- function(u,v){
          ((u^2)+(3*v^2))*exp(-(u^2)-(v^2))
          }


          Let's say you have these points:



          x0 <- seq(-3, 3, length.out = 20)
          y0 <- seq(-3, 3, length.out = 20)


          Then you can use the function parametric3d of the misc3d package, with the option fill=FALSE to get a wireframe:



          library(misc3d)
          parametric3d(fx, fy, fz, u=x0, v=y0,
          color="blue", fill = FALSE)


          enter image description here



          Is it what you want?



          To get some vertical bars, use the function segments3d of rgl:



          i <- 8
          bar <- rbind(c(x0[i],y0[i],0),c(x0[i],y0[i],f(x0[i],y0[i])))
          segments3d(bar, color="red")





          share|improve this answer























          • Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
            – Stéphane Laurent
            Nov 21 at 16:02












          • Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
            – MRT
            Nov 23 at 10:16












          • @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
            – Stéphane Laurent
            Nov 23 at 10:58










          • True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
            – MRT
            Nov 25 at 16:37










          • Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
            – MRT
            Nov 25 at 16:46














          0












          0








          0






          I'm not sure to understand what you want. If my understanding is correct, here is a solution. Define a parametric representation of your surface:



          fx <- function(u,v) u
          fy <- function(u,v) v
          fz <- function(u,v){
          ((u^2)+(3*v^2))*exp(-(u^2)-(v^2))
          }


          Let's say you have these points:



          x0 <- seq(-3, 3, length.out = 20)
          y0 <- seq(-3, 3, length.out = 20)


          Then you can use the function parametric3d of the misc3d package, with the option fill=FALSE to get a wireframe:



          library(misc3d)
          parametric3d(fx, fy, fz, u=x0, v=y0,
          color="blue", fill = FALSE)


          enter image description here



          Is it what you want?



          To get some vertical bars, use the function segments3d of rgl:



          i <- 8
          bar <- rbind(c(x0[i],y0[i],0),c(x0[i],y0[i],f(x0[i],y0[i])))
          segments3d(bar, color="red")





          share|improve this answer














          I'm not sure to understand what you want. If my understanding is correct, here is a solution. Define a parametric representation of your surface:



          fx <- function(u,v) u
          fy <- function(u,v) v
          fz <- function(u,v){
          ((u^2)+(3*v^2))*exp(-(u^2)-(v^2))
          }


          Let's say you have these points:



          x0 <- seq(-3, 3, length.out = 20)
          y0 <- seq(-3, 3, length.out = 20)


          Then you can use the function parametric3d of the misc3d package, with the option fill=FALSE to get a wireframe:



          library(misc3d)
          parametric3d(fx, fy, fz, u=x0, v=y0,
          color="blue", fill = FALSE)


          enter image description here



          Is it what you want?



          To get some vertical bars, use the function segments3d of rgl:



          i <- 8
          bar <- rbind(c(x0[i],y0[i],0),c(x0[i],y0[i],f(x0[i],y0[i])))
          segments3d(bar, color="red")






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 at 15:58

























          answered Nov 21 at 15:51









          Stéphane Laurent

          12.4k65391




          12.4k65391












          • Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
            – Stéphane Laurent
            Nov 21 at 16:02












          • Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
            – MRT
            Nov 23 at 10:16












          • @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
            – Stéphane Laurent
            Nov 23 at 10:58










          • True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
            – MRT
            Nov 25 at 16:37










          • Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
            – MRT
            Nov 25 at 16:46


















          • Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
            – Stéphane Laurent
            Nov 21 at 16:02












          • Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
            – MRT
            Nov 23 at 10:16












          • @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
            – Stéphane Laurent
            Nov 23 at 10:58










          • True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
            – MRT
            Nov 25 at 16:37










          • Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
            – MRT
            Nov 25 at 16:46
















          Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
          – Stéphane Laurent
          Nov 21 at 16:02






          Hmm... Finally I think that parametric3d is not appropriate, because it creates a grid of points from x0 and y0. But maybe it's possible to modify the source code to get something appropriate.
          – Stéphane Laurent
          Nov 21 at 16:02














          Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
          – MRT
          Nov 23 at 10:16






          Wow no I think this is good, thanks! I will try something similar and see how it looks but I’ll try and say again. What I wanted was for all the points to be connected by a net and this looks promising. I’m also new to the package and the language so I wasn’t sure of what function in the package might do what I was looking for but I think your greater knowledge has helped me.
          – MRT
          Nov 23 at 10:16














          @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
          – Stéphane Laurent
          Nov 23 at 10:58




          @MRT I'm not sure... With parametric3d you give x0 and y0 and the points are those of the grid expand.grid(x0, y0). There's no need that x0 and y0 have the same length. While in your case you don't want a grid.
          – Stéphane Laurent
          Nov 23 at 10:58












          True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
          – MRT
          Nov 25 at 16:37




          True I don't want a grid but I have just tried running it with my 1000 point resolution and it all merges together to give a smooth blue surface. One question I would like to ask is do you know enough about this function parametric3d to tell me how I can have the box around like the scatter plot I have in the question?
          – MRT
          Nov 25 at 16:37












          Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
          – MRT
          Nov 25 at 16:46




          Oh wait there is a problem. When I use only a few points the surface should look much more jagged then it does but I can't show images so I'll post a new answer after this
          – MRT
          Nov 25 at 16:46











          0














          Here is a plot with only 50 points using my original code.



          Scatter graph of 50 points



          When I then apply what was said by Stéphane Laurent I then get this plot which feels too accurate when given the actual points I have



          wire plot



          Perhaps you need to explain to me what is actually happening in the function parametric3d






          share|improve this answer

















          • 1




            I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
            – Stéphane Laurent
            Nov 28 at 7:31
















          0














          Here is a plot with only 50 points using my original code.



          Scatter graph of 50 points



          When I then apply what was said by Stéphane Laurent I then get this plot which feels too accurate when given the actual points I have



          wire plot



          Perhaps you need to explain to me what is actually happening in the function parametric3d






          share|improve this answer

















          • 1




            I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
            – Stéphane Laurent
            Nov 28 at 7:31














          0












          0








          0






          Here is a plot with only 50 points using my original code.



          Scatter graph of 50 points



          When I then apply what was said by Stéphane Laurent I then get this plot which feels too accurate when given the actual points I have



          wire plot



          Perhaps you need to explain to me what is actually happening in the function parametric3d






          share|improve this answer












          Here is a plot with only 50 points using my original code.



          Scatter graph of 50 points



          When I then apply what was said by Stéphane Laurent I then get this plot which feels too accurate when given the actual points I have



          wire plot



          Perhaps you need to explain to me what is actually happening in the function parametric3d







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 at 16:51









          MRT

          19516




          19516








          • 1




            I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
            – Stéphane Laurent
            Nov 28 at 7:31














          • 1




            I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
            – Stéphane Laurent
            Nov 28 at 7:31








          1




          1




          I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
          – Stéphane Laurent
          Nov 28 at 7:31




          I already explained :-) When, for example, you give x0 = c(1,2) and y0=c(3,4), then parametric3d uses the points c(1,3), c(1,4), c(2,3), c(2,4) (the grid obtained by "crossing" x0 and y0, the Cartesian product in other words).
          – Stéphane Laurent
          Nov 28 at 7:31


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398108%2fhow-to-plot-a-surface-in-rgl-plot3d%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen