首页 > 解决方案 > 将多个数字保存到一个 pdf-每页四个数字

问题描述

你好朋友们,我是 matplotlib 的新手,我试图将 X 个数字保存到一个 PDF 页面,该页面将在一页中表示 4 个数字

现在我将我拥有的每个图形保存到一个 PDF 文件中,但每个图形在一页中,我希望在一页中有 4 个图形

会喜欢你的帮助

NOTE-self.my_exercises 是一个练习列表,其中的每个练习都有我绘制的日期和重量

到目前为止,这是我的代码

def plot_exercise(self):
    pdf = matplotlib.backends.backend_pdf.PdfPages("FullReport.pdf")

    for exercise in self.my_exercises:
        fig, ax = plt.subplots()
        plt.plot(self.my_exercises[exercise].get_dates(), self.my_exercises[exercise].get_weights(), zorder=1)
        plt.scatter(self.my_exercises[exercise].get_dates(), self.my_exercises[exercise].get_weights(), s=10,
                    color='red', zorder=2)
        plt.suptitle(exercise[::-1])
        plt.setp(ax.xaxis.get_majorticklabels(), rotation=90, ha="right")
        plt.gcf().subplots_adjust(bottom=0.20)
        #fig.show()
        figures.append(fig)
        pdf.savefig(fig)
    pdf.close()

我在 StackOverflow 中尝试了一些代码,但我发现它们都不能帮助我的情况

标签: pythonpython-3.xmatplotlib

解决方案


推荐阅读