Skip to content

Commit bfd6a21

Browse files
Tutorial 01: Mention "pygmt.Figure.savefig" (#37)
1 parent 9abe29e commit bfd6a21

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

book/tut01_firstfigure.ipynb

+21-2
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,31 @@
214214
"fig.show()"
215215
]
216216
},
217+
{
218+
"cell_type": "markdown",
219+
"id": "d4ad78f6-22db-4999-98f3-69b70f29b17f",
220+
"metadata": {},
221+
"source": [
222+
"### 1.3 Saving a figure to a file -- [`pygmt.Figure.savefig`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.savefig)\n",
223+
"To save the figure to a file you can use the [`pygmt.Figure.savefig`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.savefig) method, and pass the desired file name and extension to the `fname` parameter."
224+
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": null,
229+
"id": "19fcd8e8-6cbe-4209-b619-73cc89acf0de",
230+
"metadata": {},
231+
"outputs": [],
232+
"source": [
233+
"fig.savefig(fname=\"my_first_figure.png\")"
234+
]
235+
},
217236
{
218237
"cell_type": "markdown",
219238
"id": "c9b6acaa-ffea-4c8a-bf2a-91b73070d06c",
220239
"metadata": {},
221240
"source": [
222-
"### 1.3 Stacking approach of GMT / PyGMT\n",
241+
"### 1.4 Stacking approach of GMT / PyGMT\n",
223242
"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",
224243
"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",
225244
"2. In a **same figure**, once you define region/projection before, you don't need to define again. "
@@ -503,7 +522,7 @@
503522
"name": "python",
504523
"nbconvert_exporter": "python",
505524
"pygments_lexer": "ipython3",
506-
"version": "3.12.7"
525+
"version": "3.12.6"
507526
},
508527
"panel-cell-order": [
509528
"eb4b43cc-dc76-45d1-a370-7266bd943910",

0 commit comments

Comments
 (0)