Code
using CairoMakie,CSV,DataFrames,Pipe,Tidier,HypertextLiteral
using MakieThemes
using StatsBase
set_theme!(ggthemr(:dust)) Makie.
load pacakge
using CairoMakie,CSV,DataFrames,Pipe,Tidier,HypertextLiteral
using MakieThemes
using StatsBase
set_theme!(ggthemr(:dust)) Makie.
=@pipe CSV.File("./data/market-share-logic-chip-production-manufacturing-stage.csv")|>DataFrame
df=coalesce.(df, 0.0) df
Row | Entity | Code | Year | Design | Fabrication | Assembly, testing and packaging |
---|---|---|---|---|---|---|
String15 | Any | Int64 | Float64 | Float64 | Float64 | |
1 | China | CHN | 2021 | 9.0 | 12.0 | 14.0 |
2 | Italy | ITA | 2021 | 0.0 | 2.0 | 0.0 |
3 | Japan | JPN | 2021 | 6.0 | 1.0 | 7.0 |
4 | Malaysia | MYS | 2021 | 0.0 | 0.0 | 2.0 |
5 | Others | 0.0 | 2021 | 9.0 | 0.0 | 5.0 |
6 | Singapore | SGP | 2021 | 0.0 | 0.0 | 2.0 |
7 | South Korea | KOR | 2021 | 6.0 | 11.0 | 13.0 |
8 | Taiwan | TWN | 2021 | 9.0 | 47.0 | 29.0 |
9 | United States | USA | 2021 | 61.0 | 27.0 | 28.0 |
=names(df)
cats=size(df)
row,_function plot_barplt(df)
=Figure()
fig=[Axis(fig[1,1]),Axis(fig[1,2]),Axis(fig[2,1])]
axs
for (idx, ax) in enumerate(axs)
=sort(df,cats[3+idx];rev=false)
df="$(cats[3+idx])"
ax.title=(1:row,df.Entity)
ax.yticks=false
ax.xgridvisible=false
ax.ygridvisible=df.Entity
xs=@pipe select(df,3+idx)|>_[:,1]|>map(x->(x/sum(_))*100,_)|>round.(_,digits=0)
ys#@info ys
barplot!(ax,1:row,ys;direction=:x,color=ys,bar_labels=:y,flip_labels_at=20,
=:dodgerblue3,
color_over_background=:white,
color_over_bar
)
end
= Label(fig[0, :], "Market share for logic chip production, by manufacturing
supertitle 2021", fontsize = 20)
stage,
fig
end
plot_barplt(df)