关于#matplotlib#的问题,如何解决?

给x坐标加上xlim出现坐标重叠的现象,我们要求图之间没有缝隙,请问怎么解决既没有缝隙又没有坐标重叠现象


import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator

fig,axs = plt.subplots(4,3,sharex=True,sharey=True,figsize=(14,8))
#创建画布,sharex是指共享x轴,figsize为图片尺寸
x_value=[0,1,2,3,4.5,6]
y_value=[4,3,2,9,4.5,7]
# plt.xlim(0.00, 7.2)

axs[0,0].plot(x_value, y_value, color='red', linewidth=1.0)
x_major_locator=MultipleLocator(0.5)
axs[2,0].xaxis.set_major_locator(x_major_locator)
# axs[0,0].set_ylabel("1")
#axs[0,0]为第一行第一列的子图,set_ylabel为给y轴添加标签
axs[0,1].plot(x_value, y_value, color='red', linewidth=1.0)

axs[0,2].plot(x_value, y_value, color='red', linewidth=1.0)

axs[2,0].plot(x_value, y_value, color='red', linewidth=1.0)

axs[2,1].plot(x_value, y_value, color='red', linewidth=1.0)

axs[2,2].plot(x_value, y_value, color='red', linewidth=1.0)

plt.subplots_adjust(left=None,bottom=None,right=None,top=None,wspace=0,hspace=0)
#hspace为调整子图之间的高度间距,同理宽度是wspace


# plt.tight_layout()
plt.show()

img

img

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。