my task is to produce maps with transparent background using PyGMT, so that I don’t need to manually delete white background in some graphical editor after.
As I understood, the only thing that I need to do is to activate transparency option in the pygmt.Figure.savefig. The problem is that even if I do so, I still get figures with the white background.
Maybe I am missing something?
My final line in the code looks like this: fig.savefig("Filename.png", transparent=True)
thank you for your answer. Your example worked for me as well. In fact, I recognized that the problem was that I had an element on my map with an activated transparency option.
So, your example will not work for me if for instance I want to add semi-transparent gridlines:
As soon as I deactivate -t option everywhere apart from fig.savefig command, I get the needed transparent background.
Maybe it is related to the versions of my packages. I am attaching the result of pygmt.show_versions() down below.