(19) Color patterns on maps
GMT supports color patterns and this example gives a few cases of how to use this new feature. We make a phony poster that advertises an international conference on GMT in Honolulu. We use grdmath, makecpt, and grdimage to draw pleasing color backgrounds on maps, and overlay coast clip paths to have the patterns change at the coastlines. The middle panel demonstrates a simple coast call where the built-in pattern # 86 is drawn at 100 dpi but with the black and white pixels replaced with color combinations. At the same time the ocean is filled with a repeating image of a circuit board (provides in PNG raster format). The text GMT in the center is an off-line PostScript file that was overlaid using image. The final panel in the 3 by 1 subplot sequence repeats the top panel except that the land and sea images have changed places.
using GMT
Glat = gmt("grdmath -Rd -I1 -r Y COSD 2 POW =")
Glon = gmt("grdmath -Rd -I1 -r X =")
lat_cpt = makecpt(color="white,blue", range=(0,1), continuous=true, no_bg=true)
lon_cpt = makecpt(cmap=:rainbow, range=(-180,180))
grdimage(Glat, cmap=lat_cpt, frame=:none, interp=:l, proj=:sinu, figsize=16, yshift=18)
coast!(area=5000, clip=:land)
grdimage!(Glon, cmap=lon_cpt, interp=:l)
coast!(clip=:end)
coast!(area=5000, shore=:thinnest)
text!(text_record([0 20], "16TH INTERNATIONAL"), font=(32,"Helvetica-Bold","red=thinner"))
text!(text_record([0 -10], "GMT CONFERENCE"), font=(32,"Helvetica-Bold","red=thinner"))
text!(text_record([0 -30], "Honolulu, Hawaii, April 1, 2019"), font=(18,"Helvetica-Bold","green=thinner"))
# Then show example of color patterns and placing a PostScript image
coast!(area=5000, land=(pattern=86, bg=:yellow, fg=:red, dpi=100), water=(pattern="@circuit.png", dpi=100), frame=:none, yshift=-8)
text!(text_record([0 30], "SILLY USES OF"), font=(32,"Helvetica-Bold","lightgreen=thinner"))
text!(text_record([0 -30], "COLOR PATTERNS"), font=(32,"Helvetica-Bold","magenta=thinner"))
psimage!("@GMT_covertext.eps", D="jCM+w3i")
# Finally repeat 1st plot but exchange the patterns
grdimage!(Glon, cmap=lon_cpt, frame=:none, interp=:l, yshift=-8)
coast!(area=5000, clip=:land)
grdimage!(Glat, cmap=lat_cpt, interp=:l)
coast!(clip=:end)
coast!(area=5000, shore=:thinnest)
text!(text_record([0 20], "15TH INTERNATIONAL"), font=(32,"Helvetica-Bold","red=thinner"))
text!(text_record([0 -10], "GMT CONFERENCE"), font=(32,"Helvetica-Bold","red=thinner"))
text!(text_record([0 -30], "Honolulu, Hawaii, April 1, 2018"), font=(18,"Helvetica-Bold","green=thinner"), show=true)
These docs were autogenerated using GMT: v1.17.0