feature :["Drivers", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21"]
1. load pacakge
Code
using CairoMakie,CSV,DataFrames,Pipe,Tidier
2. load data->dataframe
Code
feature=["Height","Weight","Bodyfat"]
df=@pipe CSV.File("./data/f1_2019_drivers_data.csv")|>DataFrame|>dropmissing
row,cor=size(df)
name=df.Drivers
score=df[:,2:end]
first(df,10)
1 |
Lewis Hamilton |
18 |
25 |
25 |
18 |
26 |
25 |
25 |
25 |
10 |
26 |
2 |
25 |
18 |
16 |
12 |
26 |
16 |
25 |
18 |
6 |
26 |
2 |
Valtteri Bottas |
26 |
18 |
18 |
25 |
18 |
15 |
13 |
18 |
15 |
18 |
0 |
4 |
15 |
18 |
10 |
18 |
25 |
15 |
25 |
0 |
12 |
3 |
Max Verstappen |
15 |
12 |
12 |
12 |
15 |
12 |
10 |
12 |
26 |
10 |
26 |
19 |
0 |
4 |
15 |
12 |
0 |
8 |
15 |
25 |
18 |
4 |
Charles Leclerc |
10 |
16 |
10 |
11 |
10 |
0 |
15 |
15 |
18 |
15 |
0 |
12 |
25 |
25 |
18 |
15 |
8 |
13 |
13 |
0 |
15 |
5 |
Sebastian Vettel |
12 |
10 |
15 |
15 |
12 |
18 |
18 |
11 |
12 |
0 |
18 |
15 |
13 |
0 |
25 |
0 |
18 |
18 |
0 |
0 |
10 |
6 |
Carlos Sainz Jnr |
0 |
0 |
0 |
6 |
4 |
8 |
0 |
8 |
4 |
8 |
10 |
10 |
0 |
0 |
0 |
8 |
10 |
0 |
4 |
15 |
1 |
7 |
Pierre Gasly |
0 |
4 |
9 |
0 |
8 |
11 |
4 |
1 |
6 |
12 |
0 |
8 |
2 |
0 |
4 |
0 |
6 |
2 |
0 |
18 |
0 |
8 |
Alexander Albon |
0 |
2 |
1 |
0 |
0 |
4 |
0 |
0 |
0 |
0 |
8 |
1 |
10 |
8 |
8 |
10 |
12 |
10 |
10 |
0 |
8 |
9 |
Daniel Ricciardo |
0 |
0 |
6 |
0 |
0 |
2 |
8 |
0 |
0 |
6 |
0 |
0 |
0 |
12 |
0 |
0 |
0 |
4 |
8 |
8 |
0 |
10 |
Sergio Perez |
0 |
1 |
4 |
8 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
8 |
6 |
0 |
6 |
4 |
6 |
1 |
2 |
6 |
3. plot
Code
f1 = ByRow(hidedecorations!)
f2 =ByRow(hidedecorations!)
with_theme(theme_black()) do
fig=Figure(resolution=(600,900))
supertitle = Label(fig[0, :], "Formula One Drivers 2019 Season Points", fontsize = 24)
grids =[fig[idx, 1] = GridLayout() for idx in 1:row]
for idx in eachindex(grids)
name=df[idx,:].Drivers
score=Vector(df[idx,2:end])
sum_score=sum(score)
al=Axis(grids[idx][1,1])
ac=Axis(grids[idx][1,2])
ar=Axis(grids[idx][1,3])
text!(al,0,0;text=name,align=(:center,:center),fontsize = 16)
barplot!(ac, 1:21,score;color=:red,strokewidth=0.3,strokecolor=(:white))
text!(ar,0,0,text="$(sum_score)",align=(:center,:center),fontsize = 16)
f1([al,ac,ar])
hidespines!(al)
hidespines!(ar)
hidespines!(ac, :t, :r,:l)
end
fig
end