Introduction to Data Visualization with Julia
Gustavo Vieira Suñe
Data Analyst
kerala
DataFrame:Date | Centre | Commodity | Price |
---|---|---|---|
JAN-2001 | Ernakulam | Onion | 10.0 |
JAN-2001 | Ernakulam | Wheat | 12.5 |
JAN-2001 | Khozhikode | Onion | 9.0 |
JAN-2001 | Khozhikode | Wheat | 14.0 |
... | ... | ... | ... |
MAR-2021 | Trivandrum | Onion | 45.0 |
MAR-2021 | Trivandrum | Wheat | 34.0 |
Commodity | Mean Price |
---|---|
Onion | 25.7442 |
Wheat | 20.6261 |
# Plot a histogram histogram( kerala[:, :Price],
# Add a label label="Onion and Wheat", # Choose bar color color=:darkseagreen1, )
# Add axis labels xlabel!("Price (Rupees)") ylabel!("Frequency")
# Plot a histogram histogram( kerala[:, :Price], # Add a label label="Onion and Wheat", # Choose bar color color=:darkseagreen1,
# Number of bins bins=20, ) # Add axis labels xlabel!("Price (Rupees)") ylabel!("Frequency")
# Plot a histogram
histogram(
kerala[:, :Price],
# Add a label
label="Onion and Wheat",
# Choose bar color
color=:darkseagreen1,
# Number of bins
bins=range(0, 150, 75),
)
# Add axis labels
xlabel!("Price (Rupees)")
ylabel!("Frequency")
# Plot a normalized histogram histogram( kerala[:, :Price], # Add a label label="Onion and Wheat", # Choose bar color color=:darkseagreen1,
# Normalize it normalize=true, ) # Add axis labels xlabel!("Price (Rupees)") ylabel!("Probability")
using StatsPlots
density!( kerala[:, :Price], color=:black, linewidth=3, label=false )
using StatsPlots # Grouped histogram groupedhist( kerala[:, :Price],
# Group by commodity group=kerala[:, "Commodity"],
# Select colors color=[:deeppink3 :wheat2] ) xlabel!("Price (Rupees)") ylabel!("Frequency")
using StatsPlots # Stacked histogram groupedhist( kerala[:, :Price], # Group by commodity group=kerala[:, "Commodity"], # Select colors color=[:deeppink3 :wheat2]
# Stack the bars bar_position=:stack, )
xlabel!("Price (Rupees)") ylabel!("Frequency")
Commodity | Mean Price |
---|---|
Onion | 25.7442 |
Wheat | 20.6261 |
Commodity | Median Price |
---|---|
Onion | 20.0 |
Wheat | 19.5 |
Introduction to Data Visualization with Julia