我有多个具有相同x轴的绘图。我想将它们堆叠在一个报告中,并让所有内容排成一列。但是,matplotlib似乎会根据y tick标签长度稍微调整它们。强制matplotlib修复绘图区域
相对于我保存的pdf画布,是否可以强制绘图区域和位置在绘图中保持相同?
import numpy as np
import matplotlib.pyplot as plt
xs=np.arange(0.,2.,0.00001)
ys1=np.sin(xs*10.) #makes the long yticklabels
ys2=10.*np.sin(xs*10.)+10. #makes the short yticklabels
fig=plt.figure() #this plot ends up shifted right on the canvas
plt.plot(xs,ys1,linewidth=2.0)
plt.xlabel('x')
plt.ylabel('y')
fig=plt.figure() #this plot ends up further left on the canvas
plt.plot(xs,ys2,linewidth=2.0)
plt.xlabel('x')
plt.ylabel('y')
您可以将它们作为子图在同一图中绘制? – DavidG
在这两种情况下,情节都具有相同的尺寸。此外,轴的尺寸也相同。目前尚不清楚你要求什么。 – ImportanceOfBeingErnest