在python中为不同的图形设置相同的框大小

jxct1oxe  于 2023-01-16  发布在  Python
关注(0)|答案(1)|浏览(126)

我试图在python matplotlib中绘制具有相同框大小的图形。基本上,我希望使每个图形的轴的高度和宽度相同(请参见下图中的红色箭头)

  1. fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(3.5,3))
  2. axes.plot([0.1,0.2,0.3])
  3. axes.set_ylabel(ylabel='Y',weight='bold')
  4. axes.set_xlabel('X',weight='bold')
  5. plt.show()

  1. fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(3.5,3))
  2. axes.plot([1,2,3])
  3. axes.set_ylabel(ylabel='Y',weight='bold')
  4. axes.set_xlabel('X',weight='bold')
  5. plt.show()

我想确定a=cB=d如果你能帮助我,我将非常感激

f3temu5u

f3temu5u1#

你是说像这样的东西吗?

  1. import matplotlib.pyplot as plt
  2. f = plt.figure(figsize=(5, 8))
  3. # rect = (left, bottom, width, height) in relative figure-units
  4. # (e.g. in the range 0-1)
  5. ax = f.add_axes(rect=(.1,.1,.8,.8))

相关问题