I’m trying to do a 3D Iris plot in Makie, but I can not figure out how to label the color dimension. Here is what I do:
using DataFrames
using WGLMakie
using RDatasets
using CategoricalArrays
iris = dataset("datasets", "iris")
f = Figure()
ax3 = Axis3(f[1,1])
scatter!(ax3, iris.SepalLength, iris.SepalWidth, iris.PetalLength; color = levelcode.(iris.Species), label = levels(iris.Species))
and this is what I get:
This is all good, but I would like a legend showing which Species maps to which color.
Calling axislegend()
gives this error:
ERROR: ArgumentError: all component arrays must have the same shape
I get the same error if I give the label argument as string.(iris.Species)
:
scatter!(ax3, iris.SepalLength, iris.SepalWidth, iris.PetalLength; color = levelcode.(iris.Species), label = string.(iris.Species)) # , colormap = cgrad(:viridis; categorical=true)) string.(iris.Species) levels(iris.Species)
It is probably just a small thing I’m doing wrong, but I was not able to find a good example online to learn from.
Hope somebody here can help.