diff --git a/Fig1_PyGMT_GMT_comparison.ipynb b/Fig1_PyGMT_GMT_comparison.ipynb new file mode 100644 index 0000000..e038222 --- /dev/null +++ b/Fig1_PyGMT_GMT_comparison.ipynb @@ -0,0 +1,136 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "0dfaa938-057e-4201-a936-a17c7a1009a9", + "metadata": {}, + "outputs": [], + "source": [ + "# The PyGMT version:\n", + "import pygmt\n", + "\n", + "fig = pygmt.Figure()\n", + "fig.basemap(projection=\"N15c\", region=[0, 360, -90, 90], frame=True)\n", + "fig.coast(land=\"tan\", water=\"lightblue\")\n", + "fig.text(position=\"MC\", text=\"GMT\", font=\"80p,Helvetica-Bold,red@75\")\n", + "fig.show()\n", + "fig.savefig(\"PyGMT_map.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7d56a075-5a02-4730-8c35-2aef38027739", + "metadata": {}, + "outputs": [], + "source": [ + "%%bash\n", + "# The GMT CLI version:\n", + "gmt begin GMT_map png\n", + " gmt basemap -JN15c -R0/360/-90/90 -B\n", + " gmt coast -Gtan -Slightblue\n", + " echo GMT | gmt text -F+f80p,Helvetica-Bold,red@75+cMC\n", + "gmt end show" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b304fb4a-d258-470f-89a7-6b2da0ca9283", + "metadata": {}, + "outputs": [], + "source": [ + "# Sequence of strings for the PyGMT code.\n", + "pygmt_str = \"\"\"\n", + "import pygmt\n", + "\n", + "fig = pygmt.Figure()\n", + "fig.basemap(projection=\"N15c\", region=[0, 360, -90, 90], frame=True)\n", + "fig.coast(land=\"tan\", water=\"lightblue\")\n", + "fig.text(position=\"MC\", text=\"GMT\", font=\"80p,Helvetica-Bold,red@@75\")\n", + "fig.show()\n", + "fig.savefig(\"PyGMT_map.png\")\n", + "\"\"\".splitlines()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c229785-c7dc-49e7-960d-c528aee8995a", + "metadata": {}, + "outputs": [], + "source": [ + "# Sequence of strings for the GMT CLI code.\n", + "# The leading tab characters are intentional to match the indentation.\n", + "gmt_str = \"\"\"\n", + "gmt begin GMT_map png\n", + "\\tgmt basemap -JN15c -R0/360/-90/90 -B\n", + "\\tgmt coast -Gtan -Slightblue\n", + "\\techo GMT | gmt text -F+f80p,Helvetica-Bold,red@@75+cMC\n", + "gmt end show\n", + "\"\"\".splitlines()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa313831-3369-4dc3-bb92-6ca7b671dd65", + "metadata": {}, + "outputs": [], + "source": [ + "import pygmt\n", + "\n", + "fig = pygmt.Figure()\n", + "pygmt.config(FONT_TITLE=\"10p\", MAP_TITLE_OFFSET=\"4p\")\n", + "fig.basemap(region=[0, 20, 0, 3], projection=\"X7.5c/2c\", frame=\"lrtb+tGMT CLI\")\n", + "fig.paragraph(\n", + " x=0.25,\n", + " y=0.6,\n", + " text=gmt_str,\n", + " parwidth=50,\n", + " linespacing=0.25,\n", + " alignment=\"left\",\n", + " justify=\"BL\",\n", + " font=\"Courier-Bold,6p\"\n", + ")\n", + "\n", + "fig.shift_origin(xshift=\"w+0.1c\")\n", + "fig.basemap(region=[0, 20, 0, 3], projection=\"X9.25c/2c\", frame=\"lrtb+tPyGMT\")\n", + "fig.paragraph(\n", + " x=0.25,\n", + " y=0.25,\n", + " text=pygmt_str,\n", + " parwidth=50,\n", + " linespacing=0.25,\n", + " alignment=\"left\",\n", + " justify=\"BL\",\n", + " font=\"Courier-Bold,6p\"\n", + ")\n", + "fig.show()\n", + "fig.savefig(\"Fig1_PyGMT_GMT_comparison.png\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pygmt", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}