본문 바로가기
수업(국비지원)/Python

[Python] matplot 시각화 모듈 - 파이그래프

by byeolsub 2023. 4. 25.

 📌

# 파이그래프
# origin 컬럼 : 제조국. [usa,japan,europe]
df_origin = df.origin.value_counts()
df_origin
type(df_origin)
#1
df_origin.plot(kind="pie") # 파이그래프
plt.title("자동차 생산국",size=20)
plt.legend(labels=df_origin.index, loc="upper left")

#2
# autopct="%.1f%%" : 파이그래프에 비율 표시
#                    %1.f : 소숫점 이하 1자리로 표시
#                    %% : %문자를 의미.
# startangle=90 : 기본설정 위치에서 90도로 시작위치를 변경
df_origin.plot(kind="pie", figsize=(7,5), autopct="%.1f%%",
               startangle=90,colors=['chocolate','bisque','cadetblue']) # 파이그래프
plt.title("자동차 생산국",size=20)
plt.legend(labels=df_origin.index, loc="upper left")