|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "eb4b43cc-dc76-45d1-a370-7266bd943910", |
| 5 | + "id": "123cc524-73bd-40e5-b727-ebef5b3b1f0b", |
6 | 6 | "metadata": {
|
7 | 7 | "panel-layout": {
|
8 | 8 | "height": 218.611,
|
|
11 | 11 | }
|
12 | 12 | },
|
13 | 13 | "source": [
|
14 |
| - "# **Tutorial 1** - First figure and subplot \n", |
15 |
| - "\n", |
16 |
| - "This tutorial will cover the fundamental concepts behind making figures with PyGMT: \n", |
17 |
| - "- drawing coastlines\n", |
18 |
| - "- drawing a map frame\n", |
19 |
| - "- choosing a projection\n", |
20 |
| - "- downloading remote dataset\n", |
21 |
| - "- imaging Earth's relief\n", |
22 |
| - "- creating colorbar\n", |
23 |
| - "- subplot in a figure\n", |
24 |
| - "\n", |
25 |
| - "-----\n", |
26 |
| - "This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", |
27 |
| - "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", |
28 |
| - "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", |
| 14 | + "# **Tutorial 1** - First figure 🚀 and Subplots / layout \n", |
| 15 | + "\n", |
| 16 | + "This tutorial will cover the fundamental concepts behind making figures with PyGMT:\n", |
| 17 | + "\n", |
| 18 | + "- Drawing coastlines\n", |
| 19 | + "- Drawing a map frame\n", |
| 20 | + "- Choosing a projection\n", |
| 21 | + "- Downloading remote dataset\n", |
| 22 | + "- Imaging Earth's relief\n", |
| 23 | + "- Creating colorbar\n", |
| 24 | + "- Subplot in a figure" |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "markdown", |
| 29 | + "id": "dfa0db02-962e-4031-a35c-4eaf4bf7d4f2", |
| 30 | + "metadata": { |
| 31 | + "panel-layout": { |
| 32 | + "height": 218.611, |
| 33 | + "visible": true, |
| 34 | + "width": 100 |
| 35 | + } |
| 36 | + }, |
| 37 | + "source": [ |
| 38 | + ":::{note}\n", |
| 39 | + "\n", |
| 40 | + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", |
29 | 41 | "- Website: https://www.generic-mapping-tools.org/agu24workshop\n",
|
30 |
| - "- Recommended version: PyGMT v0.13.0 with GMT 6.5.0\n", |
31 |
| - "----\n", |
32 |
| - "References:\n", |
| 42 | + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", |
| 43 | + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", |
| 44 | + "\n", |
| 45 | + "History\n", |
| 46 | + "- Author: [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071)\n", |
| 47 | + "- Created: November-December 2024\n", |
| 48 | + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", |
| 49 | + "\n", |
| 50 | + "References\n", |
33 | 51 | "- Liam Toney, [2021 IRIS ROSES unit05](https://github.com/roseseismo/roses2021/blob/main/unit05/roses_mapping_lecture.ipynb)\n",
|
34 |
| - "- Chih-Ming Lin, GMT courses for 2019 NTNUES summer program" |
| 52 | + "- Chih-Ming Lin, GMT courses for 2019 NTNUES summer program\n", |
| 53 | + "\n", |
| 54 | + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", |
| 55 | + "\n", |
| 56 | + ":::" |
35 | 57 | ]
|
36 | 58 | },
|
37 | 59 | {
|
|
66 | 88 | }
|
67 | 89 | },
|
68 | 90 | "source": [
|
69 |
| - "## Importing \n", |
| 91 | + "## 0️⃣ Importing \n", |
70 | 92 | "\n",
|
71 | 93 | "First thing to do is load PyGMT (`import`) so that we can access its functionality. \n",
|
72 | 94 | "\n",
|
|
88 | 110 | "id": "ce622686-4279-4ab3-b00a-a9f3e7dc8cd4",
|
89 | 111 | "metadata": {},
|
90 | 112 | "source": [
|
91 |
| - "## Starting your first figure -- [`pygmt.Figure`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.html)\n", |
92 |
| - "Every figure must start with the creation of a pygmt.Figure" |
| 113 | + "## 1️⃣ Starting your first figure -- [`pygmt.Figure`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.html)\n", |
| 114 | + "Every figure must start with the creation of a pygmt.Figure()" |
93 | 115 | ]
|
94 | 116 | },
|
95 | 117 | {
|
|
115 | 137 | "id": "03827f08-f6f5-4056-b73b-2071c90d8f0e",
|
116 | 138 | "metadata": {},
|
117 | 139 | "source": [
|
118 |
| - "## Drawing coastline -- [`pygmt.Figure.coast`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.coast.html)\n", |
| 140 | + "### 1.1 Drawing coastline -- [`pygmt.Figure.coast`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.coast.html)\n", |
119 | 141 | "Before plotting, you need to define \n",
|
120 | 142 | "1. `region`: Controlling the geographic or Cartesian extent of the figure. Regions are specified as lists of `[xmin, xmax, ymin, ymax]`. Another shortcut, `region=\"g\"`, which specifies a **global** domain.\n",
|
121 | 143 | "2. `projection`: Controlling the map projection. GMT (and therefore PyGMT) supports 31 different map projections, from basic Cartesian axes to [arbitrary vertical perspectives](https://docs.generic-mapping-tools.org/6.5/gallery/ex26.html).\n",
|
|
158 | 180 | "id": "e28639db-0e21-4c12-91b7-2a96f6158160",
|
159 | 181 | "metadata": {},
|
160 | 182 | "source": [
|
161 |
| - "::::{seealso} If the image size is too small, the default annotation fonts may appear disproportionately large, impacting the overall visual balance and readability." |
| 183 | + "::::{seealso}\n", |
| 184 | + "If the image size is too small, the default annotation fonts may appear disproportionately large, impacting the overall visual balance and readability.\n", |
| 185 | + "::::" |
162 | 186 | ]
|
163 | 187 | },
|
164 | 188 | {
|
|
167 | 191 | "id": "bc713bc7-6c8b-4709-b683-e7908b4a91ef",
|
168 | 192 | "metadata": {},
|
169 | 193 | "source": [
|
170 |
| - "#### Coloring and add map element (frame and ticks)\n", |
| 194 | + "### 1.2 Coloring and add map element (frame and ticks)\n", |
171 | 195 | "1. axis labels `WSne`: If an upper-case letter (W, S, N, E) is passed, the axis is plotted with tick marks and annotations. The lower-case version (w, s, n, e) plots the axis only with tick marks. To only plot the axis pass (l, b, t, r).\n",
|
172 | 196 | "\n",
|
173 | 197 | "2. annotations `a`: tick labels\n",
|
|
199 | 223 | "id": "c9b6acaa-ffea-4c8a-bf2a-91b73070d06c",
|
200 | 224 | "metadata": {},
|
201 | 225 | "source": [
|
202 |
| - "#### NOTE\n", |
| 226 | + "### 1.3 Stacking approach of GMT / PyGMT\n", |
203 | 227 | "1. In GMT/PyGMT, plotting is achieved by layering new elements, meaning that each new element is stacked on top of the previous layers. \n",
|
204 | 228 | "Therefore, if you draw a black line in an earlier layer and then add a new layer (such as color filling), these new layers might cover the original black line, making it invisible.\n",
|
205 | 229 | "2. In a **same figure**, once you define region/projection before, you don't need to define again. "
|
|
211 | 235 | "id": "244b61fe-c349-41ce-9dca-6eefb35d9393",
|
212 | 236 | "metadata": {},
|
213 | 237 | "source": [
|
214 |
| - "## Downloading global dataset -- [`pygmt.datasets`](https://www.pygmt.org/v0.13.0/api/index.html#datasets)\n", |
215 |
| - "\n", |
| 238 | + "## 2️⃣ Downloading global dataset -- [`pygmt.datasets`](https://www.pygmt.org/v0.13.0/api/index.html#datasets)\n", |
216 | 239 | "\n",
|
217 | 240 | "Before you access remote dataset from PyGMT, you need to define \n",
|
218 | 241 | "1. `region`: Region of interest, format is [xmin, xmax, ymin, ymax]\n",
|
|
261 | 284 | "id": "79fb24e7-fefe-45b4-b952-29f60172b76b",
|
262 | 285 | "metadata": {},
|
263 | 286 | "source": [
|
264 |
| - "## Visualizing grid -- [`pygmt.Figure.grdimage`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdimage.html)\n", |
| 287 | + "## 3️⃣ Visualizing grid -- [`pygmt.Figure.grdimage`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdimage.html)\n", |
265 | 288 | "Project and plot grids or images\n",
|
266 | 289 | "\n",
|
267 | 290 | "Now, we start with a new canvas. So you need to set up region/projection again!\n",
|
|
294 | 317 | "id": "2a1567c3-5ccd-4c17-bc2f-92fe33d4a398",
|
295 | 318 | "metadata": {},
|
296 | 319 | "source": [
|
297 |
| - "## Customizing colorbar -- [`pygmt.makecpt`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.makecpt.html)\n", |
| 320 | + "### 3.1 Customizing colorbar -- [`pygmt.makecpt`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.makecpt.html)\n", |
298 | 321 | "Making GMT color palette tables (CPT).\n",
|
299 | 322 | "\n",
|
300 | 323 | "You need to define:\n",
|
|
326 | 349 | "metadata": {},
|
327 | 350 | "source": [
|
328 | 351 | "Now, re-plot the figure with new colormap and ...\n",
|
329 |
| - "## Adding [`pygmt.Figure.colorbar`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.colorbar.html)\n", |
| 352 | + "### 3.2 Adding [`pygmt.Figure.colorbar`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.colorbar.html)\n", |
330 | 353 | "Plot a gray or color scale-bar on maps.\n",
|
331 | 354 | "\n",
|
332 | 355 | "You need to define,\n",
|
|
381 | 404 | "id": "d11eff82-e03c-4a89-9480-2860aa033ff6",
|
382 | 405 | "metadata": {},
|
383 | 406 | "source": [
|
384 |
| - "## Creating multi-panel figures in a canvas -- [`pygmt.Figure.subplot`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.subplot.html#pygmt.Figure.subplot) and [`pygmt.Figure.set_panel`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.set_panel.html#pygmt.Figure.set_panel)\n", |
| 407 | + "## 4️⃣ Creating multi-panel figures in a canvas -- [`pygmt.Figure.subplot`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.subplot.html#pygmt.Figure.subplot) and [`pygmt.Figure.set_panel`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.set_panel.html#pygmt.Figure.set_panel)\n", |
385 | 408 | "\n",
|
386 | 409 | "\n",
|
387 | 410 | "You need to define the figure layout with figure.subplot:\n",
|
|
445 | 468 | "id": "25aeb001-48ed-417b-94dc-637c3fad15c1",
|
446 | 469 | "metadata": {},
|
447 | 470 | "source": [
|
448 |
| - "### Basic projection types: \n", |
| 471 | + "## 5️⃣ Basic projection types: \n", |
449 | 472 | "\n",
|
450 | 473 | "<img src=\"_static/tut01_projection.jpg\" alt=\"position\" />\n",
|
451 | 474 | "By default, PyGMT will use an equidistant cylindrical projection if the region seems to be geographic longitude and latitude.\n",
|
|
492 | 515 | "name": "python",
|
493 | 516 | "nbconvert_exporter": "python",
|
494 | 517 | "pygments_lexer": "ipython3",
|
495 |
| - "version": "3.12.2" |
| 518 | + "version": "3.12.7" |
496 | 519 | },
|
497 | 520 | "panel-cell-order": [
|
498 | 521 | "eb4b43cc-dc76-45d1-a370-7266bd943910",
|
|
0 commit comments