Code
using CairoMakie,CSV,DataFrames,Pipe,Tidier,HypertextLiteral
using MakieThemes
using StatsBase
Makie.set_theme!(ggthemr(:dust))load pacakge
using CairoMakie,CSV,DataFrames,Pipe,Tidier,HypertextLiteral
using MakieThemes
using StatsBase
Makie.set_theme!(ggthemr(:dust))df=@pipe CSV.File("./data/market-share-logic-chip-production-manufacturing-stage.csv")|>DataFrame
df=coalesce.(df, 0.0)| 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 |
cats=names(df)
row,_=size(df)
function plot_barplt(df)
fig=Figure()
axs=[Axis(fig[1,1]),Axis(fig[1,2]),Axis(fig[2,1])]
for (idx, ax) in enumerate(axs)
df=sort(df,cats[3+idx];rev=false)
ax.title="$(cats[3+idx])"
ax.yticks=(1:row,df.Entity)
ax.xgridvisible=false
ax.ygridvisible=false
xs=df.Entity
ys=@pipe select(df,3+idx)|>_[:,1]|>map(x->(x/sum(_))*100,_)|>round.(_,digits=0)
#@info ys
barplot!(ax,1:row,ys;direction=:x,color=ys,bar_labels=:y,flip_labels_at=20,
color_over_background=:dodgerblue3,
color_over_bar=:white,
)
end
supertitle = Label(fig[0, :], "Market share for logic chip production, by manufacturing
stage, 2021", fontsize = 20)
fig
end
plot_barplt(df)