Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure.savefig: Support saving figures in PPM (.ppm) format #2771

Merged
merged 4 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,15 @@ def savefig(

Supported file formats and their extensions:

- PNG (``.png``)
- JPEG (``.jpg`` or ``.jpeg``)
- PDF (``.pdf``)
- BMP (``.bmp``)
- TIFF (``.tif``)
- GeoTIFF (``.tiff``)
- EPS (``.eps``)
- GeoTIFF (``.tiff``)
- JPEG (``.jpg`` or ``.jpeg``)
- KML (``.kml``)
- PDF (``.pdf``)
- PNG (``.png``)
- PPM (``.ppm``)
seisman marked this conversation as resolved.
Show resolved Hide resolved
yvonnefroehlich marked this conversation as resolved.
Show resolved Hide resolved
- TIFF (``.tif``)

For KML format, a companion PNG file is also generated.

Expand Down Expand Up @@ -301,14 +302,15 @@ def savefig(
"""
# All supported formats
fmts = {
"png": "g",
"pdf": "f",
"jpg": "j",
"bmp": "b",
"eps": "e",
"jpg": "j",
"kml": "g",
"pdf": "f",
"png": "g",
"ppm": "m",
"tif": "t",
"tiff": None, # GeoTIFF doesn't need the -T option
"kml": "g",
}

fname = Path(fname)
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_figure_savefig_exists():
fig = Figure()
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
prefix = "test_figure_savefig_exists"
for fmt in "png pdf jpg jpeg bmp eps tif PNG JPG JPEG Png".split():
for fmt in "bmp eps jpg jpeg pdf png ppm tif PNG JPG JPEG Png".split():
fname = ".".join([prefix, fmt])
fig.savefig(fname)

Expand Down
Loading