Number of people using the Internet”

Author

math4mad

load pacakge

Code
include("utils.jl")
[ Info: loading success

2. load data->dataframe

Code
    df=@pipe CSV.File("./data/number-of-internet-users.csv")|>DataFrame|>rename(_,"Number of Internet users"=>:num_user)|>coalesce.(_, 0.0)

first(df,5)
5×4 DataFrame
Row Entity Code Year num_user
String Any Int64 Int64
1 Afghanistan AFG 1990 0
2 Afghanistan AFG 1991 0
3 Afghanistan AFG 1992 0
4 Afghanistan AFG 1993 0
5 Afghanistan AFG 1994 0
Code
list=("World","Asia","Europe","North America","Africa","Oceania")
@eval(Main, myvars =list )
df2=@chain df begin
    @select(Entity,Year,num_user)
    @filter(Entity in !!myvars)
    @mutate(num_user=num_user/1_000_000_000)
    @arrange(desc(num_user))
end
183×3 DataFrame
158 rows omitted
Row Entity Year num_user
String Int64 Float64
1 World 2020 4.69989
2 World 2019 4.19408
3 World 2018 3.79552
4 World 2017 3.48375
5 World 2016 3.25622
6 World 2015 3.00458
7 World 2014 2.79366
8 World 2013 2.59861
9 Asia 2020 2.55759
10 World 2012 2.42685
11 Asia 2019 2.22554
12 World 2011 2.21888
13 World 2010 2.02115
172 Africa 1995 0.000324226
173 Oceania 1992 0.000318972
174 Asia 1992 0.000247731
175 Oceania 1991 0.000189499
176 Africa 1994 0.000112387
177 Oceania 1990 9.9747e-5
178 Asia 1991 9.3535e-5
179 Africa 1993 4.897e-5
180 Asia 1990 4.0687e-5
181 Africa 1992 1.6232e-5
182 Africa 1991 5.434e-6
183 Africa 1990 0.0

plot

Code
axis = (width = 1000, height =500,xticklabelrotation = pi/8,title="Internet user ",subtitle="Measured in billion.",
yticks=(1:7,["$i billion" for i in 1:7]))
data_layer = data(df2)
mapping_layer=mapping(:Year,:num_user,color=:Entity)
visual_layer = visual(ScatterLines;stroke=1,strokecolor=(:red,0.8),markersize=10,linewidth=3)
draw(data_layer * mapping_layer * visual_layer,axis=axis)
┌ Warning: Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.
└ @ Makie ~/.julia/packages/Makie/RgxaV/src/makielayout/blocks/legend.jl:23