Nhập môn Trực quan hóa Dữ liệu với Julia
Gustavo Vieira Suñe
Data Analyst



| Date | State | Centre | Product | Price |
|---|---|---|---|---|
| APR-2001 | Andhra Pradesh | Chittoor | Bathing Soap | 10.0 |
| APR-2001 | Andhra Pradesh | Chittoor | Ink | 10.0 |
| ... | ... | ... | ... | ... |
| SEP-2016 | Bihar | Patna | Paper | 38.0 |
| SEP-2016 | Bihar | Patna | Toothpaste | 50.0 |
using Statistics)# Gom nhóm theo từng sản phẩm grouped = groupby(product, :Product)# Tính giá trung bình mean_prices = combine( grouped, :Price => mean )# Sắp xếp giảm dần sorted_mean_prices = sort( mean_prices, :Price_mean, rev=true )
# Tạo biểu đồ cột bar( # Danh mục trên trục x sorted_mean_prices.Product, # Giá trị trên trục y sorted_mean_prices.Price_mean,# Đặt độ rộng cột bar_width=0.5label=false, color=:royalblue1, ) title!("Giá sản phẩm tại Ấn Độ") ylabel!("Giá trung bình (Rupee)")

# Tạo biểu đồ cột bar( # Giá trị trên trục y sorted_mean_prices.Product, # Giá trị trên trục x sorted_mean_prices.Price_mean,# Đặt hướng ngang permute=(:x, :y),label=false, color=:royalblue1, ) title!("Giá sản phẩm tại Ấn Độ") xlabel!("Giá trung bình (Rupee)")

filtered_product = filter(
row -> row.State in ["Maharashtra", "Goa", "Gujarat"],
product)
# Gom nhóm theo bang và sản phẩm filtered_grouped = groupby(filtered_product, [:State, :Product])# Tính giá trung bình filtered_mean_prices = combine( filtered_grouped, :Price => mean )
# Tạo biểu đồ cột nhóm groupedbar( # Danh mục trên trục x filtered_mean_prices.Commodity, # Giá trị trên trục y filtered_mean_prices.Price_mean,# Xác định nhóm group=filtered_mean_prices.State,color=[:teal :yellow2 :tomato3] ) title!("Giá tại Ấn Độ theo bang") ylabel!("Giá trung bình (Rupee)")

# Tạo biểu đồ cột nhóm groupedbar( # Danh mục trên trục x filtered_mean_prices.Commodity, # Giá trị trên trục y filtered_mean_prices.Price_mean, # Xác định nhóm group=filtered_mean_prices.State, color=[:teal :snow2 :tomato3],# Xếp chồng cột bar_position=:stack) title!("Giá sản phẩm tại Ấn Độ theo bang") ylabel!("Giá trung bình (Rupee)")

Nhập môn Trực quan hóa Dữ liệu với Julia