You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Plots package uses the ordering of categorical values when plotting series data, changing the order of assigning colors and in the legend. Currently, VegaLite does not respect the ordering (and appears to default to alphabetical).
MWE:
using Plots, VegaLite, DataFrames
# Sample dataframe with categorical variable
df = DataFrame(name = repeat(["a","b","c"], outer = [3]),
x = repeat([1, 2, 3], inner = [3]),
y = rand(9))
df.name = categorical(df.name)
levels(df.name)
# Plot with the original ordering (a,b,c)
df |>
@vlplot(:line,
x=:x, y=:y,
color={"name:n"})
# Change the categorical ordering and check
levels!(df.name, reverse(levels(df.name)))
levels(df.name)
# Plot with the new ordering (unchanged) -- should be (c,b,a)
df |>
@vlplot(:line,
x=:x, y=:y,
color={"name:n"})
# For reference, Plots.plot uses the new correct ordering (c,b,a)
plot(df.x, df.y, group = df.name)
The text was updated successfully, but these errors were encountered:
Yeah, I've been thinking how we could do that... I don't really want to take a dependency on CategoricalArrays.jl, that is quite an involved package. I wish there was some lightweight interface that would allow VegaLite.jl to learn about an ordering without taking a dependency on a concrete implementation of a categorical story...
The
Plots
package uses the ordering of categorical values when plotting series data, changing the order of assigning colors and in the legend. Currently,VegaLite
does not respect the ordering (and appears to default to alphabetical).MWE:
The text was updated successfully, but these errors were encountered: