Highlight country with coast -E+g; invert fill?

Using coast -E[code]+g[col] is an excellent and easy way of making a map indicating the location of a country.

But, in many ways, an ideal way would be to invert the filling. Take this arbitrarily chosen region:

gmt begin ua
gmt grdimage @earth_relief_02m -RUA -JM20c -B
gmt coast -EUA+gblack@20
gmt end show

This will paint the requested country with a black fill (with some transparency).
Any easy way to invert the filling? That is, fill everything except the country?

Stacking grdimage, then coast (everything black), then coast (UA white)?

1 Like

See -E +c vs +C for clipping. You could paint given the clip path, with basemap -B+g for instance.

1 Like

Thanks for the answer, both of you. Stacking black and white seemed a bit complicated so I went with Paul’s suggestion which worked very well;

gmt begin ua
gmt grdimage @earth_relief_02m -RUA -JM20c -B
gmt coast -EUA+C
gmt basemap -B+gblack@30
gmt coast -Q
gmt end show

Nice, don’t think I have tried this myself yet…

1 Like

Question: Is it deliberately that you have to call -B twice to get fill and axes?

To get a red fill and axes I would expect to do a:

gmt pscoast -RNO -B+gred -pdf test -W

but this does not draw the axes. I have to call -B twice:

gmt pscoast -RNO -B+gred -B -pdf test -W

That something that bothers me too sometimes.
-B is used both for “frame” and “axes”, but are called independently and can’t be mixed.
It almost always requires me a trial and error step to fix things properly… like :

gmt basemap -Bxa1Yf1Og3O -B+t"Sea-ice surface"+gwhite
1 Like

Feel free to send me a time machine so I can go back some decades and implement -B in a better way. Until then, yes, -B is broken into at least two separate settings: frame and axes, as per docs.

1 Like

Was I even born some decades ago ? I don’t want to have to deal with some weird paradoxes ! :slight_smile:

1 Like

See time machine docs or timemachine(1).

1 Like