[英]Specify colors in a Gadfly (Julia) boxplot
I am trying to reproduce this Seaborn plot using Gadfly.我正在尝试使用 Gadfly 重现这个Seaborn 情节。
The code I have so far is:我到目前为止的代码是:
using CSV, DataFrames, Gadfly
download("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv", "tips.csv")
tips = DataFrame(CSV.File("tips.csv"));
plot(
tips,
x = :day,
y = :total_bill,
color = :smoker,
Geom.boxplot,
Scale.x_discrete(levels = ["Thur", "Fri", "Sat", "Sun"]),
Theme(
key_position = :top,
boxplot_spacing = 20px
),
)
I would like to specify the colors "green" and "purple" to match the Seaborn plot.我想指定颜色“绿色”和“紫色”以匹配 Seaborn 情节。 Any suggestions how to do this in Gadfly?有什么建议如何在 Gadfly 中做到这一点?
Additional:额外的:
smoker
order from yes
to no
?如何设置smoker
顺序从yes
到no
?You need to add a line with Scale.color_discrete_manual
:您需要使用Scale.color_discrete_manual
添加一行:
using CSV, DataFrames, Gadfly
download(
"https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv",
"tips.csv",
)
tips = DataFrame(CSV.File("tips.csv"));
plot(
tips,
x = :day,
y = :total_bill,
color = :smoker,
Geom.boxplot,
Scale.x_discrete(levels = ["Thur", "Fri", "Sat", "Sun"]),
Scale.color_discrete_manual("purple", "green", order=[2, 1]),
Theme(key_position = :top, boxplot_spacing = 20px),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.