การสร้างแผนภูมิแท่ง

Python เบื้องต้นสำหรับ Data Science

Hillary Green-Lerman

Lead Data Scientist, Looker

เปรียบเทียบคดีสัตว์เลี้ยง

precinct pets_abducted
Farmburg 10
Cityville 15
Suburbia 9
plt.bar(df.precinct,
        df.pets_abducted)

plt.ylabel('Pet Abductions')
plt.show()

Python เบื้องต้นสำหรับ Data Science

แผนภูมิแท่งแนวนอน

plt.barh(df.precinct,
        df.pets_abducted)

plt.ylabel('Pet Abductions')
plt.show()

Python เบื้องต้นสำหรับ Data Science

การเพิ่ม error bar

plt.bar(df.precinct, df.pet_abductions,
        yerr=df.error)

plt.ylabel('Pet Abductions')
plt.show()

Python เบื้องต้นสำหรับ Data Science

แผนภูมิแท่งแบบเรียงซ้อน

Python เบื้องต้นสำหรับ Data Science

แผนภูมิแท่งแบบเรียงซ้อน

Python เบื้องต้นสำหรับ Data Science

แผนภูมิแท่งแบบเรียงซ้อน

Python เบื้องต้นสำหรับ Data Science

แผนภูมิแท่งแบบเรียงซ้อน

plt.bar(df.precinct, df.dog,
        label='Dog')

plt.bar(df.precinct, df.cat,
        bottom=df.dog,
        label='Cat')

plt.legend()
plt.show()

Python เบื้องต้นสำหรับ Data Science

มาฝึกกันเถอะ!

Python เบื้องต้นสำหรับ Data Science

Preparing Video For Download...