Plots for the Board Room
Pie Chart
- The pie chart is a simple plot that conveys relative proportions.
- Plot in Julia
using CSV, CategoricalArrays, DataFrames, Plots; pyplot()
df = CSV.read("../data/companyData.csv", DataFrame)
companies = levels(df.Type)
year2012 = df[df.Year .== 2012, :MarketCap]
year2016 = df[df.Year .== 2016, :MarketCap]
p1 = pie(companies, year2012, title="2012 Market Cap \n by company")
p2 = pie(companies, year2016, title="2016 Market Cap \n by company")
plot(p1, p2, size=(800,400))
Bar Plot
- The bar plot is another useful plot which conveys proportions through the use of vertical bars
using CSV, CategoricalArrays, DataFrames, StatsPlots; pyplot()
df = CSV.read("../data/companyData.csv", DataFrame)
years = levels(df.Year)
data = reshape(df.MarketCap, 5, 3)
p1 = groupedbar(years, data, bar_position=:stack)
p2 = groupedbar(years, data, bar_position=:dodge)
plot(p1, p2, bar_width=0.7, fill=[:blue :red :green], label=["A" "B" "C"],
ylims=(0, 6), xlabel="Year", ylabel="Market Cap (MM)",
legend=:topleft, size=(800, 400))
Stack Plot
- The stack plot is commonly used plot which shows how constituent amounts of a metric change over time.
using CSV, CategoricalArrays, DataFrames, Plots; pyplot()
df = CSV.read("../data/companyData.csv", DataFrame)
mktCap = reshape(df.MarketCap, 5,3)
years = levels(df.Year)
areaplot(years, mktCap,
c=[:blue :red :green], label=["A" "B" "C"],
xlims=(minimum(years), maximum(years)), ylims=(0, 6.5),
legend=:topleft, xlabel="Years", ylabel="MarketCap")