州別堆疊
在這個練習中,你將探索並比較印度 3 個邦(Jammu and Kashmir、Bihar、Punjab)的多種食物商品價格。為了便於分析,你會使用群組化直方圖,並將代表不同商品的長條彼此堆疊。
為了方便你,DataFrames 和 StatsPlots 套件已經匯入。另有 commodities DataFrame 可直接使用,內含本次分析所需的相關資料。
本練習屬於課程
Julia 資料視覺化入門
練習說明
- 使用
commoditiesDataFrame 的Retail Price欄位產生群組化直方圖。 - 以
State欄位作為分組,並依序將顏色指定為limegreen、fuchsia、orange1代表各州。 - 使用
bar_position參數將長條彼此堆疊。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create grouped histogram
____(
____."____",
# Define groups and colors
____=____.____,
color=[____],
# Stack the bars
bar_position=:____
)
title!("Commodity Prices in India")
xlabel!("Price (Rupees)")
ylabel!("Frequency")