Hi, I’m trying to make a “dotplot”, e.g. see here, with Plots.jl. It mostly works, but I would like to order the categorical values that are shown on the y-axis.
But the plot does not honor this sorting. I even sorted the whole DataFrame by :volume and that didn’t change the ordering of the values on the y-axis. Does anyone know how to order the categorical values on the y-axis? Thanks! – Adam
An easy way to do it would be to replace :volume with a number specifying the y location, then override yticks to show the names, e.g. scatter(:when, :numvolume, ticks = (1:14, levels(:volume)). But agreed it would make sense if StatPlots would respect the level-order of ordered categorical columns.
Ups, my bad, so the problem is not supporting the container type but supporting categorical values. In particular seems like we should allow categorical values in Plots using their own ordering. Not sure why the @df macro would work at all then, will investigate.
EDIT: actually at least in my hands it does not work:
julia> @df df scatter(:x, :x)
ERROR: No user recipe defined for CategoricalArrays.CategoricalValue{Int64,UInt32}
I wonder if this is something the @df macro should take care of or if it’s actually simpler to fix it in Plots (may be as simple as widening some method signatures to accept categorical values).
Would be best to fix in Plots IMHO. Maybe just having a type recipe on them? I guess the ordering means they need some special treatment. Essentially they should be treated more like symbols/strings in the code I guess.