Introduction to Data Visualization with 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)# Group by each product grouped = groupby(product, :Product)# Calculate average prices mean_prices = combine( grouped, :Price => mean )# Sort from higest to lowest sorted_mean_prices = sort( mean_prices, :Price_mean, rev=true )
# Create bar chart bar( # Categories in x-axis sorted_mean_prices.Product, # Values in y-axis sorted_mean_prices.Price_mean,# Set bar width bar_width=0.5label=false, color=:royalblue1, ) title!("Product Prices in India") ylabel!("Average Price (Rupees)")

# Create bar chart bar( # Values in the y-axis sorted_mean_prices.Product, # Values in x-axis sorted_mean_prices.Price_mean,# Set orientation to horizontal permute=(:x, :y),label=false, color=:royalblue1, ) title!("Product Prices in India") xlabel!("Average Price (Rupees)")

filtered_product = filter(
row -> row.State in ["Maharashtra", "Goa", "Gujarat"],
product)
# Group by state and product filtered_grouped = groupby(filtered_product, [:State, :Product])# Calculate average prices filtered_mean_prices = combine( filtered_grouped, :Price => mean )
# Create grouped bar chart groupedbar( # Categories in x-axis filtered_mean_prices.Commodity, # Values in y-axis filtered_mean_prices.Price_mean,# Define groups group=filtered_mean_prices.State,color=[:teal :yellow2 :tomato3] ) title!("Prices in India by State") ylabel!("Average Price (Rupees)")

# Create grouped bar chart groupedbar( # Categories in x-axis filtered_mean_prices.Commodity, # Values in y-axis filtered_mean_prices.Price_mean, # Define groups group=filtered_mean_prices.State, color=[:teal :snow2 :tomato3],# Stack the bars bar_position=:stack) title!("Product Prices in India by State") ylabel!("Average Price (Rupees)")

Introduction to Data Visualization with Julia