Private Investment on AI by focus

Author

math4mad

Code
include("utils.jl")
[ Info: loading success
Code
make_title("Part 1 : data processing")

2. load data->dataframe

Code
df=@pipe CSV.File("./data/private-investment-in-artificial-intelligence-by-focus-area.csv")|>DataFrame
rename!(df,"European Union and United Kingdom"=>:EU,"United States"=>:US)
select!(df,Not("Code"))
160×6 DataFrame
135 rows omitted
Row Entity Year World EU China US
String Int64 Int64 Int64 Int64 Int64
1 AI ventures 2017 705626292 34720055 233168581 404163765
2 AI ventures 2018 1539250299 30321937 591347599 857474812
3 AI ventures 2019 1212544984 15388467 93042361 962517568
4 AI ventures 2020 1545821073 5170265 91954563 1358836062
5 AI ventures 2021 2379370717 1013359242 258977775 923024967
6 AI ventures 2022 1242838005 14814431 451988999 641729703
7 Agricultural technology 2017 309478503 7554717 10391318 261846503
8 Agricultural technology 2018 280024054 33194058 0 194254290
9 Agricultural technology 2019 502672339 116117865 18018197 283437548
10 Agricultural technology 2020 686735808 25459779 7959031 624487776
11 Agricultural technology 2021 1351178581 469886955 0 838525337
12 Agricultural technology 2022 810137282 76739673 95402811 509921645
13 Augmented or virtual reality 2017 313686338 28642184 156899836 107616472
149 Total 2017 28434536002 2687729049 7314151975 15548790772
150 Total 2018 46508641939 2955166939 15069705393 22716597215
151 Total 2019 58389972850 6202067697 14892596238 30795184157
152 Total 2020 64505628706 5599432467 17094749150 35531472847
153 Total 2021 125356874235 12500782453 22848295305 73395940859
154 Total 2022 85055265067 10217823819 12412402667 43848726664
155 Venture capital 2017 160103509 9424792 115426266 15476426
156 Venture capital 2018 217600809 0 107910146 109690663
157 Venture capital 2019 106903067 26497349 0 28617137
158 Venture capital 2020 179347432 0 124590452 4502008
159 Venture capital 2021 225784599 0 0 60011724
160 Venture capital 2022 14814431 14814431 0 0
Code
df2=@chain df begin 
   @pivot_longer(_, 3:6, names_to =area, values_to =investment)
   @mutate(investment=investment/10_000_000_000)
   @group_by(Entity)
   @arrange(Year)
   @ungroup
   @filter(Entity  ["Medical and healthcare","Data management","Cybersecurity","Industrial automation","Semiconductors","Drones"])
end
144×4 DataFrame
119 rows omitted
Row Entity Year area investment
String Int64 String Float64
1 Cybersecurity 2017 World 0.247797
2 Cybersecurity 2017 EU 0.0211647
3 Cybersecurity 2017 China 0.0799647
4 Cybersecurity 2017 US 0.0895792
5 Cybersecurity 2018 World 0.407162
6 Cybersecurity 2018 EU 0.0172524
7 Cybersecurity 2018 China 0.0583573
8 Cybersecurity 2018 US 0.191833
9 Cybersecurity 2019 World 0.411088
10 Cybersecurity 2019 EU 0.0161193
11 Cybersecurity 2019 China 0.196212
12 Cybersecurity 2019 US 0.171356
13 Cybersecurity 2020 World 0.379812
133 Semiconductors 2020 World 0.092762
134 Semiconductors 2020 EU 0.00523489
135 Semiconductors 2020 China 0.0207361
136 Semiconductors 2020 US 0.0576268
137 Semiconductors 2021 World 0.0632604
138 Semiconductors 2021 EU 0.00857049
139 Semiconductors 2021 China 0.020434
140 Semiconductors 2021 US 0.0156559
141 Semiconductors 2022 World 0.153211
142 Semiconductors 2022 EU 0.00114812
143 Semiconductors 2022 China 0.0946097
144 Semiconductors 2022 US 0.0536569
Code
 make_title("Part 2 :Plot")
Code
data_layer=data(df2)
  map_layer=mapping(:Year,:investment,layout=:Entity,color=:area)
  visual_layer = visual(Lines,linewidth=2)
  
  plt=data_layer*map_layer*visual_layer
  draw(plt,legend=(position=:bottom, titleposition=:left, framevisible=true, padding=2),facet = (;linkyaxes = :true))
┌ Warning: Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.
└ @ Makie ~/.julia/packages/Makie/RgxaV/src/makielayout/blocks/legend.jl:23