Code
include("utils.jl")[ Info: loading success
include("utils.jl")[ Info: loading success
df=@pipe CSV.File("./data/irish.csv")|>DataFrame|>dropmissing
first(df,5)| Row | category | quality | country | year | cases |
|---|---|---|---|---|---|
| String15 | String15 | String | Int64 | Int64 | |
| 1 | Irish Whiskey | Standard | United States | 1990 | 243000 |
| 2 | Irish Whiskey | Standard | United States | 1991 | 214000 |
| 3 | Irish Whiskey | Standard | United States | 1992 | 219500 |
| 4 | Irish Whiskey | Standard | United States | 1993 | 225000 |
| 5 | Irish Whiskey | Standard | United States | 1994 | 239500 |
df1=@chain df begin
@select(country,year, cases)
#@filter(country in ["Ireland","Germany","Russia","France"])
@group_by(country,year)
@summarize(country,year,sales=sum(cases)/1000)
@ungroup
#@mutate(cases=cases/1000)
# @filter(country in ["Ireland","Germany","Russia"])
# @group_by(country)
# #@arrange(year)
# @mutate(cases =cases.-cases[1])
# @ungroup
unique!(_)
@group_by(country)
@arrange(year)
@mutate(sales =sales.-sales[1])
@ungroup
end
all_country_data=@chain df1 begin @filter(country ∉ ["Ireland","Germany","Russia","France"])
end
Ireland_data=@chain df1 begin @filter(country == "Ireland")
end
four_country_data=@chain df1 begin @filter(country ∈ ["Ireland","Germany","Russia","France","Spain"])
end| Row | country | year | sales |
|---|---|---|---|
| String | Int64 | Float64 | |
| 1 | Ireland | 1990 | 0.0 |
| 2 | Ireland | 1991 | 9.5 |
| 3 | Ireland | 1992 | -26.5 |
| 4 | Ireland | 1993 | -13.0 |
| 5 | Ireland | 1994 | -12.5 |
| 6 | Ireland | 1995 | -22.5 |
| 7 | Ireland | 1996 | -2.4 |
| 8 | Ireland | 1997 | 7.8 |
| 9 | Ireland | 1998 | 9.25 |
| 10 | Ireland | 1999 | 49.15 |
| 11 | Ireland | 2000 | 52.1 |
| 12 | Ireland | 2001 | 53.35 |
| 13 | Ireland | 2002 | 32.8 |
| ⋮ | ⋮ | ⋮ | ⋮ |
| 123 | Russia | 2005 | 39.75 |
| 124 | Russia | 2006 | 63.25 |
| 125 | Russia | 2007 | 102.75 |
| 126 | Russia | 2008 | 146.75 |
| 127 | Russia | 2009 | 132.0 |
| 128 | Russia | 2010 | 182.0 |
| 129 | Russia | 2011 | 307.25 |
| 130 | Russia | 2012 | 365.25 |
| 131 | Russia | 2013 | 387.25 |
| 132 | Russia | 2014 | 445.75 |
| 133 | Russia | 2015 | 290.5 |
| 134 | Russia | 2016 | 293.5 |
ran=-100:50:350
axis = (width = 500, height =500,xticks=(ran,["$(i)k" for i in ran]), xticklabelrotation = pi/8,
titlealign = :center,titlesize=24,
title="The Twisted Nature of Irish Whiskey Sales",
subtitle = rich(
"Within Europe sales have increased 225% since 1990. While" , rich("Ireland's",color =:blue), "sales have decreased",rich("Russia, France \n and Germany", color =:green),"sales to have than made up the difference.")
)
data_layer1=data(four_country_data)
data_layer2=data(Ireland_data)
#data_layer3=data(all_country_data)
mapping_layer1=mapping(:sales,:year,color=:country)
mapping_layer2=mapping(:sales,:year)
visual_layer1 = visual(Lines,linewidth=3)
visual_layer2 = visual(Lines, linewidth=8,color=:blue)
#visual_layer3 = visual(Lines, linewidth=1,color=(:gray,0.3))
four_lines=data_layer1* mapping_layer1 * visual_layer1
ireland_line=data_layer2* mapping_layer2 * visual_layer2
#all_lines=data_layer3* mapping_layer2 * visual_layer3
draw(four_lines+ ireland_line ,axis=axis)┌ Warning: Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.
└ @ Makie ~/.julia/packages/Makie/RgxaV/src/makielayout/blocks/legend.jl:23