Size of an OffsetImage when saving as PDF?

Dear Matplotlibers,

I'm trying to insert a logo image (from PNG) in the top left corner of my axes. I'm doing this by reading the logo using read_png() and inserting it as an OffsetImage in an AnnotationBox. When saving the figure as PNG everything is based on pixel sizes and I know how to scale the OffsetImage such that I end up with the desired logo size (based on the figure and logo sizes in pixels). Saving as PDF, however, does not depend on pixel sizes, and I end up with a 'different' size of the logo.

Could someone please tell me what determines the size of the OffsetImage when saving as PDF? And maybe even better, how to achieve scaling that results in the same size logo as in the PNG output?

I have attached:
1a) A small script that produces PNG and PDF output showing the different logo sizes. Uncommenting the zoom_factor line shows how to scale the logo independent of the figure size/dpi settings.
1b) A dummy PNG logo file.
2) Two example output files (PNG and PDF) showing the output of

Any hints would be much appreciated!

Best regards,


test.pdf (10.4 KB)

test.png (1.14 KB)