【发布时间】:2017-05-01 21:10:43
【问题描述】:
【问题讨论】:
标签: python matplotlib
【问题讨论】:
标签: python matplotlib
您可以执行以下操作:
# Use this code to get the axes
axs = plt.axes()
# Here you set where de y axis begins and ends
# In this case, the y axis end will be 20% bigger than the biggest value in your y list of values (MC_SIM)
axs.set_ybound(lower=0, upper=max(MC_SIM)*1.2)
【讨论】:
如果x轴上的点等距,可以设置条的宽度等于x坐标之间的差,
plt.bar(x, y, width=x[1]-x[0])
如果 x 坐标不等间距,则需要提供宽度列表,对应于连续条之间的距离。
为了在条形之间仍留出一些空间,您可以调整宽度。例如。如果你想在条形之间有 20% 的间距,
plt.bar(x, y, width=(x[1]-x[0])*0.8)
要显示大纲,请使用ec="black" 作为进一步的参数。
【讨论】: