Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3D scatter plot in Julia

Working in Julia and using Plots, I have an array of points that lie on two distinct surfaces. The points are mixed together such that doing a surface plot looks like garbage, because it tries to connect points on the two surfaces. I think the best way to get around this is to plot the points simply as dots in space.

How do I plot points in 3D without connecting them by a surface?

like image 918
Yly Avatar asked Jan 29 '19 20:01

Yly


People also ask

How do you make a 3 dimensional scatter plot?

Generally 3D scatter plot is created by using ax. scatter3D() the function of the matplotlib library which accepts a data sets of X, Y and Z to create the plot while the rest of the attributes of the function are the same as that of two dimensional scatter plot.

What is a Julia plot?

Plots is a visualization interface and toolset. It sits above other backends, like GR, PyPlot, PGFPlotsX, or Plotly, connecting commands with implementation. If one backend does not support your desired features or make the right trade-offs, you can just switch to another backend with one command.

Which package is used to plot 3D scatter plot?

Building a 3d scatterplot requires a dataset with 3 numeric variables, each being used on an axis. Here, the famous iris dataset is used. The rgl package comes with the plot3d() function that is pretty close from the base R plot() function.


2 Answers

You can use scatter from Plots.

Just pass the coordinates of points as 3 arrays to scatter function

X = [x1, x2, x3]
Y = [y1, y2, y3]
Z = [z1, z2, z3]

scatter(X, Y, Z)
like image 196
Uziel Linares Avatar answered Sep 28 '22 15:09

Uziel Linares


Using Plots:

plt3d= Plots.plot(points[1,:],points[2,:], points[3,:],
     seriestype=:scatter, markersize = 7)
display(plt3d)

In the above, I assume the points are in a 3x<num_of_points> array. Also increased the marker size, as the 3d plots default is small.

like image 41
Dinari Avatar answered Sep 28 '22 17:09

Dinari