use*_*828 3 python matplotlib pandas
如何使 xlabel 和 ylabel 在下图中可见?
import pandas as pd
import matplotlib.pyplot as plt
a = {'Test1': {1: 21867186, 4: 20145576, 10: 18018537},
'Test2': {1: 23256313, 4: 21668216, 10: 19795367}}
d = pd.DataFrame(a).T
#print d
f = plt.figure()
plt.xlabel("xTEST")
plt.ylabel("yTEST")
plt.ticklabel_format(style = 'plain')
plt.title('Title here!', color='black')
d.plot(kind='bar', ax=f.gca())
plt.show()
Run Code Online (Sandbox Code Playgroud)
当我运行你的例子时,xlabel 和 ylabel 在我的绘图上,根据它的大小,在显示器外面一点。
尝试添加以下行:
plt.subplots_adjust(bottom=.25, left=.25)
Run Code Online (Sandbox Code Playgroud)
或者简单地拉伸显示窗口。