A weird issue related to subplot

I’m trying to plot 3 maps as 3 subplots in one figure. Below is my code. Why doesn’t my region setting being honored when my land_clip and my variable contour are plotted using grdimage? BTW, each of the 3 maps plotted very well as separate ones.

subplot(grid=(3,1), region=(0, 100, 0, 80), panels_size=8, margins="5p", autolabel=true, col_axes=(bott=true,), row_axes=(left=true,), axes="wstr",  savefig=F1);

    subplot(:set); 
    coast(region=(180,320,15,80));
    grdimage! ...
    ... 

    subplot(:set); 
    coast(region=(180,320,15,80));
    grdimage! ...
    ... 

    subplot(:set); 
    coast(region=(180,320,15,80));
    grdimage! ...
    ...

Here is the plot:
test2|196x500

Many thanks!!

grdimage after a coast obviously hides the coastlines. But why don’t you post something we can try?

Many thanks, @Joaquim.

Below is a shorter version of my code:

using GMT;

Land_clip = grdclip("@earth_relief_05m", low=[0 NaN]); # Remove ocean areas

subplot(grid=(3,1), panels_size=8, margins="5p",
autolabel=true, col_axes=(bott=true,), row_axes=(left=true,), axes="wstr",
savefig="Variable.jpg");

subplot(:set);
coast!(region=(180,320,15,80));
grdimage!(Land_clip, color=:geo, nan_alpha=true, shade=false,
xaxis=(annot=15, grid=30, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
yaxis=(annot=15, grid=15, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
par=(MAP_GRID_PEN_PRIMARY="0.005p",), coast=true);

subplot(:set);
coast!(region=(180,320,15,80));
grdimage!(Land_clip, color=:geo, nan_alpha=true, shade=false,
xaxis=(annot=15, grid=30, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
yaxis=(annot=15, grid=15, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
par=(MAP_GRID_PEN_PRIMARY="0.005p",), coast=true);

subplot(:set);
coast!(region=(180,320,15,80));
grdimage!(Land_clip, color=:geo, nan_alpha=true, shade=false,
xaxis=(annot=15, grid=30, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
yaxis=(annot=15, grid=15, FONT_ANNOT_PRIMARY="12p,Helvetica,black",),
par=(MAP_GRID_PEN_PRIMARY="0.005p",), coast=true);

subplot(:show)

This is wrong. I warned a couple of times. grdimage overlaps the coastlines.

grdimage after a coast obviously hides the coastlines.

This is twice the coastlines

1 Like

But the true problem is this bug (the region is not what was asked)

grdimage(Land_clip, region=(-180,-40,15,80), color=:geo, xaxis=(annot=15, grid=30), yaxis=(annot=15, grid=15), Vd=1, show=1)
 grdimage  -R-180/-40/15/80 -JX14c/0 -Bpya15g15 -Bpxa15g30 -n+a -Cgeo -P -K > C:\TEMP\GMTjl_tmp.ps

No idea where it comes from. I suggest that you crop the grid at the same time you clip it to avoid this. i.e:

Land_clip = grdclip("@earth_relief_05m", low=[0 NaN], region=(-180,-40,15,80));

1 Like

Thank you so much! This solution fixes the issue.

Note, this problem does dot occur if one use a projection other than a linear one.

1 Like