Skip to content

Commit b6740e5

Browse files
committed
Finish PyGMT script for Ch7; working on PyGMT script for Ch8
1 parent 8f57942 commit b6740e5

7 files changed

Lines changed: 507 additions & 73 deletions

File tree

SOURCE_DOCS/cpt_colormap/iceland_glacier_speed_pygmt.ipynb

Lines changed: 110 additions & 0 deletions
Large diffs are not rendered by default.
291 KB
Loading

SOURCE_DOCS/locale/en_US/LC_MESSAGES/scatter_plot.po

Lines changed: 127 additions & 69 deletions
Large diffs are not rendered by default.

SOURCE_DOCS/scatter_plot.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,53 @@ XY 點散佈圖
392392
393393
觀看\ `最終版圖片`_
394394
395+
PyGMT 指令稿
396+
--------------------------------------
397+
398+
使用 PyGMT,可以如下腳本繪製本地圖:
399+
400+
.. code-block:: python
401+
402+
import pygmt
403+
import numpy as np
404+
# 需要 Numpy 來讀取檔案中的資料
405+
406+
# ==== 設定變數 ====
407+
# 我們使用 numpy.loadtxt 載入資料表,然後資料點樣式使用 Python 的 Dictionary 來指定。
408+
zzh = np.loadtxt('zzh.txt', delimiter=',')
409+
suao = np.loadtxt('suao.txt', delimiter=',')
410+
zzh_style = {'style': 'c0.35c', 'color': '#58C73A', 'pen': '0.03c,black'}
411+
suao_style = {'style': 'd0.35c', 'color': '#3A6BC7', 'pen': '0.03c,black'}
412+
413+
fig = pygmt.Figure()
414+
415+
# ==== 版面與作圖區設定 ====
416+
fig.basemap(region=[-1, 23, 0, 7], projection='X15c/10c', frame=['WSne+t"January 2016"', 'xaf+l"Temperature (@.C)"', 'ya2f+l"Wind Speed (m s@+-1@+)"'])
417+
418+
# ==== 繪點 ====
419+
fig.plot(data=zzh, **zzh_style)
420+
fig.plot(data=suao, **suao_style)
421+
422+
# ==== 灰色垂直虛線 ====
423+
fig.plot(x=[0, 0], y=[0, 7], pen='0.03c,100,--')
424+
425+
# ==== 圖例框與圖例內容 ====
426+
fig.plot(x=[16, 22, 22, 16], y=[5, 5, 6.5, 6.5], pen='0.05c,black', color='#E6F4F2')
427+
fig.plot(data=[[17, 6.05]], **zzh_style)
428+
fig.plot(data=[[17, 5.45]], **suao_style)
429+
fig.text(x=18, y=6.05, text='Zhuzihu', font='14p', justify='ML')
430+
fig.text(x=18, y=5.45, text="Su'ao", font='14p', justify='ML')
431+
432+
fig.show()
433+
fig.savefig('windspeed_vs_temperature_pygmt.png')
434+
435+
436+
你可以使用以下的 Binder 連結嘗試此程式碼:
437+
438+
.. image:: https://mybinder.org/badge_logo.svg
439+
:target: https://mybinder.org/v2/gh/whyjz/GMT-tutorials/HEAD?filepath=SOURCE_DOCS%2Fscatter_plot%2Fwindspeed_vs_temperature_pygmt.ipynb
440+
441+
395442
習題
396443
--------------------------------------
397444
1. 本章使用的資料事實上是依照時間排序的,每日只有一個測量數值。因此,請利用本章中提供的數據,畫出竹子湖與蘇澳測站在 2016 年 1 月份的氣溫每日變化的\ **折線圖**。

SOURCE_DOCS/scatter_plot/windspeed_vs_temperature_pygmt.ipynb

Lines changed: 172 additions & 0 deletions
Large diffs are not rendered by default.
60.8 KB
Loading

_build/locale/scatter_plot.pot

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: GMT 教學手冊 1.2\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-02-23 11:56-0500\n"
11+
"POT-Creation-Date: 2021-03-18 14:30-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -494,17 +494,64 @@ msgid "觀看\\ `最終版圖片`_"
494494
msgstr ""
495495

496496
#: ../../SOURCE_DOCS/scatter_plot.rst:396
497+
msgid "PyGMT 指令稿"
498+
msgstr ""
499+
500+
#: ../../SOURCE_DOCS/scatter_plot.rst:398
501+
msgid "使用 PyGMT,可以如下腳本繪製本地圖:"
502+
msgstr ""
503+
504+
#: ../../SOURCE_DOCS/scatter_plot.rst:400
505+
msgid "import pygmt\n"
506+
"import numpy as np\n"
507+
"# 需要 Numpy 來讀取檔案中的資料\n"
508+
"\n"
509+
"# ==== 設定變數 ====\n"
510+
"# 我們使用 numpy.loadtxt 載入資料表,然後資料點樣式使用 Python 的 Dictionary 來指定。\n"
511+
"zzh = np.loadtxt('zzh.txt', delimiter=',')\n"
512+
"suao = np.loadtxt('suao.txt', delimiter=',')\n"
513+
"zzh_style = {'style': 'c0.35c', 'color': '#58C73A', 'pen': '0.03c,black'}\n"
514+
"suao_style = {'style': 'd0.35c', 'color': '#3A6BC7', 'pen': '0.03c,black'}\n"
515+
"\n"
516+
"fig = pygmt.Figure()\n"
517+
"\n"
518+
"# ==== 版面與作圖區設定 ====\n"
519+
"fig.basemap(region=[-1, 23, 0, 7], projection='X15c/10c', frame=['WSne+t\"January 2016\"', 'xaf+l\"Temperature (@.C)\"', 'ya2f+l\"Wind Speed (m s@+-1@+)\"'])\n"
520+
"\n"
521+
"# ==== 繪點 ====\n"
522+
"fig.plot(data=zzh, **zzh_style)\n"
523+
"fig.plot(data=suao, **suao_style)\n"
524+
"\n"
525+
"# ==== 灰色垂直虛線 ====\n"
526+
"fig.plot(x=[0, 0], y=[0, 7], pen='0.03c,100,--')\n"
527+
"\n"
528+
"# ==== 圖例框與圖例內容 ====\n"
529+
"fig.plot(x=[16, 22, 22, 16], y=[5, 5, 6.5, 6.5], pen='0.05c,black', color='#E6F4F2')\n"
530+
"fig.plot(data=[[17, 6.05]], **zzh_style)\n"
531+
"fig.plot(data=[[17, 5.45]], **suao_style)\n"
532+
"fig.text(x=18, y=6.05, text='Zhuzihu', font='14p', justify='ML')\n"
533+
"fig.text(x=18, y=5.45, text=\"Su'ao\", font='14p', justify='ML')\n"
534+
"\n"
535+
"fig.show()\n"
536+
"fig.savefig('windspeed_vs_temperature_pygmt.png')"
537+
msgstr ""
538+
539+
#: ../../SOURCE_DOCS/scatter_plot.rst:436
540+
msgid "你可以使用以下的 Binder 連結嘗試此程式碼:"
541+
msgstr ""
542+
543+
#: ../../SOURCE_DOCS/scatter_plot.rst:443
497544
msgid "習題"
498545
msgstr ""
499546

500-
#: ../../SOURCE_DOCS/scatter_plot.rst:397
547+
#: ../../SOURCE_DOCS/scatter_plot.rst:444
501548
msgid "本章使用的資料事實上是依照時間排序的,每日只有一個測量數值。因此,請利用本章中提供的數據,畫出竹子湖與蘇澳測站在 2016 年 1 月份的氣溫每日變化的\\ **折線圖**。"
502549
msgstr ""
503550

504-
#: ../../SOURCE_DOCS/scatter_plot.rst:399
551+
#: ../../SOURCE_DOCS/scatter_plot.rst:446
505552
msgid "請利用 ``plot`` 畫出「`大衛之星 <https://zh.wikipedia.org/wiki/%E5%A4%A7%E8%A1%9B%E6%98%9F>`_」。"
506553
msgstr ""
507554

508-
#: ../../SOURCE_DOCS/scatter_plot.rst:401
555+
#: ../../SOURCE_DOCS/scatter_plot.rst:448
509556
msgid "`頻果日報,2016 年 1 月 24 日新聞 <http://www.appledaily.com.tw/realtimenews/article/new/20160124/782086/>`_。"
510557
msgstr ""

0 commit comments

Comments
 (0)