我试图使用matplotlib绘制三个图形,但是图像的显示方式不清楚,我尝试使用诸如 plt.tight_layout()和 plt.subplots_adjust( left = 0.1,bottom = 0.1,right = 0.5,top = 1.0,wspace = 0.5,hspace = 0.5),但它们都不起作用。
我不太确定问题是否出在我正在使用的IDE(Visual Studio代码)上,还是有办法在同一python函数内部绘制单张图。如果有人对如何改进显示图形的方式有任何想法。
def program_graph(year):
...
fig,axes = plt.subplots(nrows=3, ncols = 1)
risk_info_srv_evesa.plot.bar(ax = axes[0])
risk_info_act_pln.plot.bar(ax = axes[1])
final_db.plot.bar(ax = axes[2])
axes[0].title.set_text('SRV-EVESOS per Program')
axes[1].title.set_text('Action Plan per Program')
axes[2].title.set_text('SRV-EVESOS Vs Action Plan')
plt.tight_layout()
plt.subplots_adjust(left=0.4, bottom=0.1, right=0.5, top=1.0, wspace=0.5, hspace=0.5)
plt.show()
我认为最好的解决方案是分别显示每个图,但是我不想为每个图实现不同的功能。有人知道如何解决这个问题吗?