I have a rather long map (250 lines of python) I’m exporting composed of a few subplots. I’ve spent a few hours trying to export it with a transparent background and referred to some questions here on the forum, but I’ve been unable to find a solution. I’ve copied an example from the forums and modified to for a minimum working example that should yield transparent backgrounds, but doesn’t. I figure this is the right place to start.
All exported images end up with white backgrounds.
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True)
fig.savefig(fname="test.png", transparent=True, gs_path=r"C:\Program Files\gs\gs10.05.1\bin\gswin64c")
my configs are:
PyGMT information:
version: v0.15.0
System information:
python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]
executable: C:\Users\USERNAME\anaconda3\python.exe
machine: Windows-10-10.0.19045-SP0
Dependency information:
numpy: 2.2.3
pandas: 2.2.3
xarray: 2024.11.0
netCDF4: 1.7.2
packaging: 24.2
contextily: None
geopandas: 0.14.4
IPython: 8.30.0
pyarrow: 19.0.0
rioxarray: None
gdal: None
ghostscript: 9.54.0
GMT library information:
version: 6.5.0
padding: 2
share dir: c:/programs/gmt6/share
plugin dir: c:/programs/gmt6/bin/gmt_plugins
library path: c:/programs/gmt6/bin/gmt_w64.dll
cores: 24
grid layout: rows
image layout:
binary version: 6.5.0
I installed gs on windows and manually put the path in as gs_path in my code, but no difference in output was observed between manual and auto gs_path.
I’d also settle for setting a background color in any unique color so I can remove it manually.
What am I missing?



