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?
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.
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.
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.
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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With