Description
The API can be used to create an image file with exactly the same instructions as a script. However, with or without the A option on the gmt begin
line, the figure is not cropped when gmt end show
is called.
Take this simple script:
gmt begin toto_script jpg
gmt basemap -BWESN -Bxa30mg30m -Bya20mg20m -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1r
gmt end show
resulting in this image:
The same instructions via the API:
int main () {
void *API;
/* Initialize the GMT session */
if ((API = GMT_Create_Session ("GMT_plot", 2, 0, NULL)) == NULL)
return EXIT_FAILURE;
GMT_Call_Module(API, "begin", GMT_MODULE_CMD, "toto_api jpg");
GMT_Call_Module(API, "basemap", GMT_MODULE_CMD, "-BWESN -Bxa30mg30m -Bya20mg20m -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1r");
GMT_Call_Module(API, "end", GMT_MODULE_CMD, "show");
/* Destroy session */
if (GMT_Destroy_Session (API))
return EXIT_FAILURE;
}
produce a different image, not cropped:
Running gmt end show -Vd
reveals the difference between script and API processing:
From script:
end [DEBUG]: psconvert: '/home/sarzeaud/.gmt/sessions/gmt_session.14414/gmt_0.ps-' -Tj -Ftoto -A
From C program (-A option is missing):
end [DEBUG]: psconvert: '/home/sarzeaud/.gmt/sessions/gmt_session.14414/gmt_0.ps-' -Tj -Ftoto
The result is the same whether or not we use the A option on the gmt begin
line.
System information
- Operating system: Debian stretch
- GMT version (
gmt --version
): 6.2.0_d266c30_2020.11.25