How to graph a scatter plot in 3D?

Hello. I currently have the following scatter plot, and here is an image of it:

https://imgur.com/8jAzcKX

I am trying to graph this scatter plot on a 3D scatter plot using the packages plot3D and plot3Drgl. However, I am having trouble doing so. What would be the best way to accomplish this. Thanks, I'm very new to R.

Welcome to R and this community.

Have you checked out the scatterplot3d package?

Also, take a look at its vignette.

I've tried using scatterplot3d, but I want to be able to rotate it. Also, I want there to be no depth on the 3D plot, and specifically, I have to use those packages in order to make the plot.

If it helps I sort of want it to look like this:
https://imgur.com/BOiPkMv

To get the most out of this community, you should e familiar with this post:

To know how to create a REPRoducible EXample (reprex), please go through the following post:

Now, I can create what you want quite easily with the plot3Drgl package as follows:

# loading library
library(plot3Drgl)

# simulating co-ordinates
sim_x <- rnorm(n = 100)
sim_y <- rnorm(n = 100)
sim_z <- rnorm(n = 100)

# plotting 3D scatterplot
scatter3Drgl(x = sim_x,
             y = sim_y,
             z = sim_z,
             colvar = NULL)

I don't know how to upload an interactive plot here. If you run this, you'll get a new window where you will be able to rotate, zoom, etc. You can explore more options from the documentation.

Note that, I only plotted the points, instead of joining them. I didn't quite understand how did you plot your diagram. One of the points (labelled Sada-Melik or something like that) is connected to two points, which makes me think that you may be plotting vertices and edges separately. If you want to plot a graph, I think igraph package will be useful, but I haven't used it much.

Hope this helps.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.