မေးခွန်းနဲ့ ကိုက်တဲ့ Chart ရွေးခြင်း

3.11.2

Category၊ trend၊ distribution နဲ့ ဆက်နွှယ်မှုတွေကို ဘယ် chart နဲ့ ပြမလဲ ရွေးပါ။

ဒီစာမျက်နှာမှာ

Category များ ယှဉ်ခြင်းနှင့် အချိန်အလိုက် ပြောင်းလဲမှု ပြခြင်း

သီးခြား category တွေ ယှဉ်ဖို့ bar chart သုံးပါ။ တန်ဖိုးပမာဏကို bar အရှည်နဲ့ ပြတဲ့အတွက် axis ကို သုညကနေ စပါ။ အချိန်လို အစဉ်လိုက်ကြည့်ရတဲ့ data အတွက် line chart သုံးပါ။ ရက်စွဲတွေ အညီအမျှ မခြားရင် ရက်စွဲတန်ဖိုးအတိုင်း ဆွဲမှ အကွာအဝေးက ကြားကာလကို ကိုယ်စားပြုပါမယ်။

import matplotlib.pyplot as plt

fig, (by_store, by_month) = plt.subplots(1, 2, layout="constrained")
bars = by_store.bar(["A", "B", "C"], [8, 12, 6])
by_store.bar_label(bars)
by_store.set(ylim=(0, 14), xlabel="Store", ylabel="Orders")

by_month.plot(["Jan", "Feb", "Mar"], [20, 24, 22], marker="o")
by_month.set(xlabel="Month", ylabel="Orders")
plt.show()
Bar chart က ဆိုင် A၊ B၊ C ရဲ့ order 8၊ 12၊ 6 ကို ယှဉ်ပြပါတယ်။ Line chart က January ကနေ March အထိ order 20၊ 24၊ 22 ကို ပြပါတယ်။ ပုံဖိုင် ဒေါင်းလုဒ်လုပ်ရန်
Chart နှစ်ခုလုံး order အရေအတွက်ကို တိုင်းတာပါတယ်။ Chart တစ်ခုစီ ဘာကို ယှဉ်ပြလဲဆိုတာ x-axis မှာ ကြည့်နိုင်ပါတယ်။

Distribution သို့မဟုတ် ဆက်နွှယ်မှု ပြခြင်း

Histogram က ကိန်းဂဏန်း column တစ်ခုရဲ့ တန်ဖိုးတွေကို range အလိုက် စုပါတယ်။ Bin အကျယ် ပြောင်းပြီး မြင်ရတဲ့ pattern တည်ငြိမ်လား စစ်ပါ။ Scatter plot မှာ observation တစ်ခုစီကို ကိန်းဂဏန်းနှစ်ခုက သတ်မှတ်တဲ့ နေရာမှာ အမှတ်တစ်ခုနဲ့ ပြပါတယ်။ Pattern ကို အဓိပ္ပာယ်မဖော်ခင် အမှတ်ထပ်နေတာ၊ ထူးခြားတဲ့ အမှတ်နဲ့ အုပ်စုခွဲတွေ ရှိမရှိ ကြည့်ပါ။

import matplotlib.pyplot as plt

fig, (histogram, scatter) = plt.subplots(1, 2, layout="constrained")
durations = [12, 16, 17, 22, 24, 28, 33, 35]
histogram.hist(durations, bins=[10, 20, 30, 40], edgecolor="white")
histogram.set(xlabel="Duration (min)", ylabel="Deliveries")

distance = [1, 2, 2.5, 3, 4, 5, 5.5, 6]
scatter.scatter(distance, durations)
scatter.set(xlabel="Distance (km)", ylabel="Duration (min)")
plt.show()
Histogram မှာ ကြာချိန်အုပ်စု သုံးစုထဲ delivery 3၊ 3၊ 2 ခု အသီးသီးရှိပါတယ်။ Scatter plot မှာ delivery ရှစ်ခုရဲ့ အကွာအဝေးနဲ့ ကြာချိန်ကို ပြပါတယ်။ ပုံဖိုင် ဒေါင်းလုဒ်လုပ်ရန်
Delivery ကြာချိန် data တစ်မျိုးတည်းကို သီးခြားဆွဲတာနဲ့ အကွာအဝေးနဲ့ တွဲဆွဲတာက မေးခွန်းနှစ်မျိုးကို ဖြေပေးပါတယ်။

တရားဝင် ကိုးကားချက်များ