DataFrame에서 간단한 막대 그림을 만듭니다.pyplot.plot()이 width = 1, height = 1 인 추가 Rectangle을 만드는 이유는 무엇입니까?
import pandas as pd
import matplotlib as mpl
df = pd.DataFrame({'City': ['Berlin', 'Munich', 'Hamburg'],
'Population': [3426354, 1260391, 1739117]})
df = df.set_index('City')
ax = df.plot(kind='bar')
가 지금은 각각의 막대에 액세스하려면 생성 된 플롯을하다 (시리즈 및 DataFrame의 플롯 방법은 pyplot.plot 주위 단순한 래퍼입니다).
Rectangle(xy=(-0.25, 0), width=0.5, height=3.42635e+06, angle=0)
Rectangle(xy=(0.75, 0), width=0.5, height=1.26039e+06, angle=0)
Rectangle(xy=(1.75, 0), width=0.5, height=1.73912e+06, angle=0)
Rectangle(xy=(0, 0), width=1, height=1, angle=0)
내가 여기에 세 개의 사각형을 기대 : 그리고 제가 발견 한 것은 폭 = 1 추가 바 (사각형) = 1
rects = [rect for rect in ax.get_children() if isinstance(rect, mpl.patches.Rectangle)]
for r in rects:
print(r)
출력 높이가 있다는 것입니다. 네 번째의 목적은 무엇입니까?
이미지에 대한 링크를 게시하십시오. 누군가 당신을 위해 그것을 고칠 것입니다. –