Images that are added to an axis with MatPlotLib imshow() are enlarged when a pdf document is generated and minimized when a plt.show() is performed

I am making some plots with data, which I insert an image in an axis and crop them corresponding to the data I have.

The document I get is the following: In the first axis I plot the images, which in total are 3 different ones corresponding to a different texture.

In this way I save the document in pdf:

pdf = matplotlib.backends.backend_pdf.PdfPages("outputTestLog.pdf")
pdf.savefig(fig, edgecolor='white')
pdf.close()
plt.show()

Now, when I visualize the plt.show() I see that the images are super minimized:

But when I zoom in I can see that if you can appreciate the complete images in the graph, compared to the first image of the pdf document that the images overlapped to the left and right. What changes is the index of the “X” axis, so I do not understand how I can make the images do not exceed the limit values of the axis when saving the graph as a pdf file.

I leave the necessary resources of the project for your better understanding: GitHub - MarcosGuerreroA/DataLog