09. 막대 그래프 심화
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 #한글폰트 사용시 마이너스 글자 깨짐 해결
옆으로 길쭉한 그래프 그리기
In [5]:
labels = ['강백호','서태웅','정대만'] #이름
values= [190, 187, 184] #키
plt.barh(labels, values)
Out[5]:
<BarContainer object of 3 artists>

In [7]:
labels = ['강백호','서태웅','정대만'] #이름
values= [190, 187, 184] #키
plt.barh(labels, values)
plt.xlim(175,195)
Out[7]:
(175.0, 195.0)

In [14]:
bar = plt.bar(labels, values)
bar[0].set_hatch("x")
bar[1].set_hatch("/")
bar[2].set_hatch("++")

In [21]:
bar= plt.bar(labels, values)
plt.ylim(175,195)
for idx, rect in enumerate(bar):
plt.text(idx,rect.get_height()+0.5,values[idx], ha= 'center', color = 'blue')

'Programming > python' 카테고리의 다른 글
[matplotlib] 누적 막대 그래프 (0) | 2023.03.27 |
---|---|
[matplotlib] Data Frame (0) | 2023.03.27 |
[matplotlib] 막대그래프 (0) | 2023.03.27 |
[matplotlib] 여러 데이터 (0) | 2023.03.27 |
[matplotlib] 텍스트 넣기 (0) | 2023.03.27 |