-1

Sorry for the question, but I have a variable that I would like to plot like this: enter image description here

I am a newby on R, so I am having some difficulties. I appreciate any kind of help. Thanks!

Leonor
  • 29
  • 7
  • 4
    there are several packages, did you try googling the title of this question? – rawr Jan 29 '16 at 15:12
  • Have you tried to make a surface plot using the `plotly` package? https://plot.ly/r/3d-surface-plots/ – d-roy Jun 18 '16 at 21:01

1 Answers1

1

Since you're looking to plot what appears to be a 3d surface, I'd suggest starting with the persp function, from the graphics package. This blog post (http://www.r-bloggers.com/3d-plots-in-r/) gives a good treatment of several options for 3D plotting:

the generic function persp() in the base graphics package draws perspective plots of a surface over the x–y plane. Typing demo(persp) at the console will give you an idea of what this function can do.

And running demo(persp) gives you a number of examples, including this one:

enter image description here

There are also some more suggestions for going further:

The plot3D package from Karline Soetaert builds on on persp()to provide functions for both 2D and 3D plotting. [...] Load the package and type the following commands at the console: example(persp3D), example(surf3D) and example(scatter3D) to see examples of 3D surface and scatter plots.

As a side note, @rawr's comment is spot on - I found all this in less than a minute, using two google searches - one of which was the title of your post. I'm putting this answer up anyway, since StackOverflow posts frequently become the top google result for many topics. But the best advice I can give you going forward is that R is one of the most aggressively well-documented languages out there, both in terms of formal and informal documentation, and you can find a lot just by googling what you want to do.

Empiromancer
  • 3,778
  • 1
  • 22
  • 53
  • Thanks! I try this scatterplot3d(Y, X, Z, main= "Runoff", pch=20, type="h") Although I don't get the image that I need..I get several points, but not the surface image type that I need, – Leonor Jan 29 '16 at 18:10
  • @Leonor In general, you've got a much better shot at getting the help you need if you include in your question a minimum reproducible example (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) showing what you've already tried to do to solve the problem, and being specific about what the problem you're trying to solve is. As it stands, I can only give you my best guess - it looks like you're using a function designed to create scatterplots, and you're getting a scatterplot as a result. – Empiromancer Jan 29 '16 at 20:20