2017-10-17 105 views

回答

1

可以设置轴到-.5len(df)-.5的限制,以避免在条形图的边缘。

import matplotlib.pyplot as plt 
import pandas as pd 
plt.rcParams["patch.force_edgecolor"] = True 

df = pd.DataFrame([1,2]) 
df.plot.bar(width=1) 
plt.xlim(-0.5,len(df)-.5) 
plt.show() 

enter image description here