[Python] Combine plots from separate pdfs into one in python

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have created several plots and saved each one separately in its own PDF file using the following line of code:

    plt.savefig('/path/Plot1.pdf', format='pdf', bbox_inches='tight', dpi=600)


    Now, I need to combine some of these plots—let's say four of them—into a single file arranged in a 2x2 grid, without reducing the resolution of the original plots. Additionally, I need to add a title to this new combined plot. The final result should look something like this:

    Big title
    Plot1 Plot2
    Plot3 Plot4


    How can I do this in python ? I tried using the fitz package but there's something wrong with it, I keep getting this error :

    ----> 1 from frontend import *
    2 import tools
    3 import os.path as op

    ModuleNotFoundError: No module named 'frontend'


    I tried following some answers here but it's for merging pages, not merging plots from pdfs. Note that the plots inside the pdfs are not exactly images.. please see how I saved them above.

    Continue reading...

Compartilhe esta Página