python matplotlib x축이 생략되어 나타납니다.

22.12.05 22:17 작성 조회수 497

1

import pandas as pd

import matplotlib.pyplot as plt

# 한글폰트 사용시 그래프에서 마이너스 폰트 깨지는 문제에 대한 대처

plt.rcParams['axes.unicode_minus'] = False

plt.rc('font', family='Malgun Gothic')

styles = ['-', '--', '-.', ':']

pd.set_option('mode.chained_assignment', None)

#

df = pd.read_csv('2021-univ-HR.txt',sep='\t',encoding='euc-kr')

df1=df.loc[:,["지역","학교유형","설립","대학규모","정규-전담-계","비정규-전담-계","정규-겸직-계","비정규-겸직-계"]]

df2=pd.melt(df1, id_vars =['지역'], value_vars=['정규-전담-계','비정규-전담-계'])

df3=df2.groupby(['지역','variable']).mean().reset_index()

df3.set_index("지역", inplace=True)

print(df3)

plt.subplot(2,2,1)

plt.xticks()

df3.groupby("variable")["value"].plot(legend=True, xlabel="지역", ylabel="평균 인원",ax=plt.gca(), rot=45)

위와 같은 코드의 결과가-------------------------------

캡처.PNG캡처1.PNG

이렇게 나오는데요 '지역'이 모두 x축에 나타나지 않고 자동적으로 생략되어 나옵니다..

강원부터 충북까지 모든 지역이 그래프에서 표시되려면 어떻게 해야 할까요??

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!