I'm trying to produce a pdf file (with PdfFile) containing several figures in one page.
The most obvious solution is to use subplots. However, in my case this is not possible because each plot is produced by a different function. For example, there is a function def plotPDF(inputData) that will plot a probability distribution function (PDF), and another function def plotCDF(inputData) that will plot a cumulative distribution function (CDF). My code contains up to 20 different functions that will produce different plots when they are called.
What I want to do is to select some of these plots and produce a pdf file where they are contained in the same page. Following the example of PDF and CDF, I would like to produce a pdf file which contains one page where both plots are next to each other (in a similar way to the subplots).
I have tried to do this with subplots, but I cannot directly call the function within a subplot. That is, the following code wouldn't work:
fig, ax = plt.subplots(nrows=1, ncols=2)
plt.subplot(1, 2, 1)
plotPDF(inputData)
plt.subplot(1, 2, 2)
plotCDF(inputData)
plt.show()
Does anybody know how to solve this issue ? I need to proceed like this because I need the plot functions to be independent for other purposes. Making subplots would mean changing this structure, and it would make the code less versatile.
Thanks in advance !