Dataframe 如何使用Julia package Gadfly对箱线图中的分类变量进行排序

Dataframe 如何使用Julia package Gadfly对箱线图中的分类变量进行排序,dataframe,julia,boxplot,categorical-data,gadfly,Dataframe,Julia,Boxplot,Categorical Data,Gadfly,Gadfly似乎没有使用分类变量的(级别)顺序: using CSV using DataFrames using Gadfly using HTTP url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv" tips = CSV.File(HTTP.get(url).body) |> DataFrame categorical!(tips, :day) ordere

Gadfly似乎没有使用分类变量的(级别)顺序:

using CSV
using DataFrames
using Gadfly
using HTTP

url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv"

tips = CSV.File(HTTP.get(url).body) |> DataFrame
categorical!(tips, :day)
ordered!(tips.day, true)
levels!(tips.day, ["Thur", "Fri", "Sat", "Sun"])

Gadfly.plot(tips, x=:day, y=:total_bill, color=:smoker, Geom.boxplot)

绘图是否应继承分类变量中指定的顺序

我找到了一种对分类值进行排序的方法,但由于再次指定了顺序,因此感觉有点“错误”

Gadfly.plot(tips, x=:day, y=:total_bill, color=:smoker, Geom.boxplot,
    Scale.x_discrete(levels=levels(tips.day)))


有什么建议可以解决这个问题吗?

在Gadfly中,对于离散的
x
值的顺序由它们在数据帧中的顺序决定(因此目前不支持CategoricalArray中的级别顺序)。将来可能不支持它,因为DataFrames计划删除CategoricalArray()。

在Gadfly中,对于离散的
x
,值的顺序由它们在dataframe中的顺序决定(因此目前不支持CategoricalArray中的级别顺序)。将来可能不支持它,因为DataFrames计划删除CategoricalArray()。

我不知道DataFrames是否依赖CategoricalArray这一事实对Gadfly有什么影响。请参阅Plots的类似问题。jl:我不认为数据帧依赖于CategoricalArray与否这一事实对Gadfly有什么关系。参见Plots.jl的类似问题: