Skip to content

Commit 5f5653f

Browse files
Add a gallery example for the fig.image() method (#777)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent f8e3f27 commit 5f5653f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/gallery/plot/image.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Images or EPS files on maps
3+
---------------------------
4+
The :meth:`pygmt.Figure.image` method can be used to read and
5+
place a raster image file or an Encapsulated PostScript file
6+
on a map. We must specify the file as *str* via the ``imagefile``
7+
argument or simply use the filename as first argument. You can
8+
also use a full URL pointing to your desired image. The ``position``
9+
argument allows us to set a reference point on the map for the image.
10+
11+
For more advanced style options, see the full option list
12+
at :gmt-docs:`image.html`.
13+
"""
14+
15+
import pygmt
16+
17+
fig = pygmt.Figure()
18+
19+
fig.basemap(region=[0, 2, 0, 2], projection="X6c", frame=True)
20+
21+
# place and center the GMT logo from the GMT website to the position 1/1
22+
# on a basemap and draw a rectangular border around the image
23+
fig.image(
24+
imagefile="https://www.generic-mapping-tools.org/_static/gmt-logo.png",
25+
position="g1/1+w3c+jCM",
26+
box=True,
27+
)
28+
29+
fig.show()

0 commit comments

Comments
 (0)