我正在使用 matplotlib 绘制一些图形。通常,标准做法是从图形的尺寸开始并指定轴的尺寸,以便图形随后缩放到可用空间。
但是我有一个请求来扩展图表的高度以容纳 y 轴上的异常数据。
我知道我可以使用 Figure.figsize
来指定整体尺寸,但是一旦包含边距,这将无法使图表保持比例。有没有一种方法可以指定实际的子图大小或相反地确定默认边距大小的边距大小并相应地调整图形的尺寸?
你的意思是这样的?您需要计算利润率。
import matplotlib.pyplot as plt
subplotsize=[5.,5.]
figuresize=[10.,10.]
left = 0.5*(1.-subplotsize[0]/figuresize[0])
right = 1.-left
bottom = 0.5*(1.-subplotsize[1]/figuresize[1])
top = 1.-bottom
fig=plt.figure(figsize=(figuresize[0],figuresize[1]))
fig.subplots_adjust(left=left,right=right,bottom=bottom,top=top)
ax=fig.add_subplot(111)
plt.show()
我是一名优秀的程序员,十分优秀!