2017-12-28 3 views
0

나는 DateTime 인덱스가있는 pandas DataFrame을 가지고 있습니다.matplotlib에서 x 축 날짜/시간 라벨 지정하기

나는 timeseries를 그려 볼 수 있으며, 기본적으로 괜찮아 보입니다.

그러나 동일한 DataFrame에서 막 대형 차트를 인쇄하려고하면 xAxis 레이블이 망가집니다 (대량 겹침). (또한 데이터의 간격은 내가 autoformat_xdate()을 시도,하지만 아무것도 도움이되지 않았다

바 세트) 사이에 이상한 (큰 격차입니다.

enter image description here

이 내가 사용하는 간단한 코드 조각입니다 차트를 생성하는

entire_df['predict'] = regr.predict(entire_df[X_cols]) 
entire_df['error'] = entire_df['predict']-entire_df['px_usd_mmbtu'] 
#entire_df['error'].plot(kind='hist') 
fig=plt.figure() 
entire_df[['px_usd_mmbtu', 'predict']].plot() 
fig2 = plt.figure() 
entire_df['error'].plot(kind='bar') 
#fig2.autofmt_xdate()    #doesn't help 
print (type(error_df.index)) 

답변

0

이 시도 :

entire_df['predict'] = regr.predict(entire_df[X_cols]) 
entire_df['error'] = entire_df['predict']-entire_df['px_usd_mmbtu'] 

plt.figure(figsize=(15,15)) 
plt.xticks(rotation = 90) # or change from 90 to 45 

#entire_df['error'].plot(kind='hist') 

entire_df[['px_usd_mmbtu', 'predict']].plot() 
entire_df['error'].plot(kind='bar') 
관련 문제