13. 원 그래프 (기본)
In [3]:
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'AppleGothic'
matplotlib.rcParams['font.size'] = 15 #글자크기
matplotlib.rcParams['axes.unicode_minus'] = False #한글폰트 사용시 마이너스 글자 깨짐 해결
자동으로 각 레이블 별 퍼센트 생성 autopct = '%.1f%%'
In [17]:
values = [30, 25, 20, 13, 10, 2]
labels= ['Python','Java','Javascript','C#','C++','ETC']
plt.pie(values, labels= labels, autopct = '%.1f%%', startangle=90, counterclock = False)
plt.show()

피자 간 간격 explode
In [19]:
values = [30, 25, 20, 13, 10, 2]
labels= ['Python','Java','Javascript','C#','C++','ETC']
explode = [0.2, 0.1, 0,0,0,0]
plt.pie(values, labels = labels, explode = explode)
plt.show()

In [20]:
values = [30, 25, 20, 13, 10, 2]
labels= ['Python','Java','Javascript','C#','C++','ETC']
explode = [0.05] *6
plt.pie(values, labels = labels, explode = explode)
plt.show()

In [26]:
plt.pie(values, labels = labels, explode = explode)
plt.title('언어 별 선호도')
plt.legend(loc=(1.2,0.3), title = '언어')
plt.show()

'Programming > python' 카테고리의 다른 글
[matplotlib] 원 그래프 (심화) (0) | 2023.03.27 |
---|---|
[matplotlib] 원그래프 (심화) (0) | 2023.03.27 |
[matplotlib] 다중막대 그래프 (0) | 2023.03.27 |
[matplotlib] 누적 막대 그래프 (0) | 2023.03.27 |
[matplotlib] Data Frame (0) | 2023.03.27 |