不等面积应该只能用subplot来实现,因为subplots返回的是Axes对象数组,不能像subplot一样指定绘图的区域。
subplots会报错
import numpy as np
import matplotlib.pyplot as plt
fig,ax=plt.subplots(2,2)
x=np.linspace(1,10,100)
y=x
ax[0].plot(x,y)
ax[1,0].plot(x,y)
ax[1,1].plot(x,y)
plt.show()用subplot实现
import numpy as np
import matplotlib.pyplot as plt
ax1=plt.subplot(121)
ax2=plt.subplot(2,2,2)
ax3=plt.subplot(224)
x=np.linspace(1,10,100)
y=x
ax1.plot(x,y)
ax2.plot(x,y)
ax3.plot(x,y)
plt.show()margins方法设置刻度的宽度,注意到是先把刻度的宽度确定了,再自动确定坐标轴的显示范围。
import numpy as np
import matplotlib.pyplot as plt
ax1=plt.subplot(121)
ax2=plt.subplot(2,2,2)
ax3=plt.subplot(224)
x=np.linspace(1,10,100)
y=x
ax1.plot(x,y)
ax1.margins(0.3)
ax2.plot(x,y)
ax3.plot(x,y)
plt.show()