Introduzione alla visualizzazione dei dati con Julia
Gustavo Vieira Suñe
Data Analyst



| Data | Stato | Centro | Prodotto | Prezzo |
|---|---|---|---|---|
| APR-2001 | Andhra Pradesh | Chittoor | Sapone da bagno | 10.0 |
| APR-2001 | Andhra Pradesh | Chittoor | Inchiostro | 10.0 |
| ... | ... | ... | ... | ... |
| SEP-2016 | Bihar | Patna | Carta | 38.0 |
| SEP-2016 | Bihar | Patna | Dentifricio | 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!("Prezzi dei prodotti in India") ylabel!("Prezzo medio (rupie)")

# 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!("Prezzi dei prodotti in India") xlabel!("Prezzo medio (rupie)")

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!("Prezzi in India per stato") ylabel!("Prezzo medio (rupie)")

# 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!("Prezzi dei prodotti in India per stato") ylabel!("Prezzo medio (rupie)")

Introduzione alla visualizzazione dei dati con Julia