Makie scatter plot of vector of points

I would like to pass a vector of 3D points:

v = Vector{Point3f0}(undef, 10)

to scatter plot. Do I have to separate it into x, y and z columns first and call:

scene = scatter(x, y, z, color = :red, markersize = 0.02)

or there is a simpler way?

BTW, why name the type Point3f0 instead of Point3f?

1 Like

I think this was chosen in reference to the f0 suffix for Float32 literals:

julia> typeof(1.2)
Float64

julia> typeof(1.2f0)
Float32

But I agree it’s confusing, since the 0 in f0 is incidental… 1.2f3 is also valid syntax for a Float32. So Point3f would make more sense, and it is also more usual. These types are defined in GitHub - JuliaGeometry/GeometryBasics.jl: Basic Geometry Types . Maybe it would be worth filing an issue to suggest changing it.

1 Like

It should just work to pass the Vector of points to the plotting function?

3 Likes

Issue filed at Rename Point3f0 and similar to Point3f, etc. · Issue #61 · JuliaGeometry/GeometryBasics.jl · GitHub

1 Like

Indeed it does:

scatter(rand(Point3f0, 10), color = :red, markersize = 0.02)

I’m just learning my ABCs and asking silly questions.

No worries, I was just wondering given the way you phrased the question whether you had encountered a bug

Out of curiosity, how did you know this would work? I can’t find any example using this syntax… I would have tried scatter([x y z]) (which fails) but wouldn’t have guessed scatter(Point3f0.(x,y,z))). It also seems hard to find it by reading https://makie.juliaplots.org/stable/signatures.html

1 Like

I’ve been using Makie for a while, so I just knew. But I don’t know if it’s explicitly mentioned in the docs somewhere

1 Like