diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index b6575fd..5630096 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -53,14 +53,26 @@ "state": { "type": "markdown", "state": { - "file": "00. Inbox/想要的鏡頭.md", + "file": "04. Programming/Python/tkinter.md", "mode": "preview", "source": true } } + }, + { + "id": "7f135903a7f5dcc6", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "04. Programming/Python/matplotlib.md", + "mode": "source", + "source": true + } + } } ], - "currentTab": 3 + "currentTab": 4 } ], "direction": "vertical" @@ -89,7 +101,7 @@ "state": { "type": "search", "state": { - "query": "hugo", + "query": "matplot", "matchingCase": false, "explainSearch": false, "collapseAll": false, @@ -118,7 +130,7 @@ "state": { "type": "backlink", "state": { - "file": "00. Inbox/想要的鏡頭.md", + "file": "04. Programming/Python/matplotlib.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -143,7 +155,7 @@ "state": { "type": "outline", "state": { - "file": "00. Inbox/想要的鏡頭.md" + "file": "04. Programming/Python/matplotlib.md" } } }, @@ -194,11 +206,13 @@ "periodic-notes:Open today": false } }, - "active": "d5d9792133b0bc1c", + "active": "7f135903a7f5dcc6", "lastOpenFiles": [ + "04. Programming/Python/tkinter.md", + "04. Programming/Python/matplotlib.md", + "00. Inbox/想要的鏡頭.md", "00. Inbox/01. TODO.md", "01. 個人/01. Daily/2023-04-17(週一).md", - "00. Inbox/想要的鏡頭.md", "05. 資料收集/仰臥起坐.md", "attachments/Pasted image 20230418111538.png", "attachments/Pasted image 20230418111512.png", @@ -228,7 +242,6 @@ "01. 個人/01. Daily/2023/03/2023-04-06(週四).md", "01. 個人/01. Daily/2023/03/2023-03-09(週四).md", "未命名.canvas", - "01. 個人/01. Daily/2023/03/2023-03-08(週三).md", "attachments/android_mediacodec_life_cycle.png", "attachments/android_mediacodec_flow.png", "attachments/Pasted image 20230308105856.png", diff --git a/04. Programming/Python/matplotlib.md b/04. Programming/Python/matplotlib.md new file mode 100644 index 0000000..fd83c65 --- /dev/null +++ b/04. Programming/Python/matplotlib.md @@ -0,0 +1,54 @@ +## 基本折線圖 +給2個list,一個 x,一個 y +```python +plt.clf() # 把圖清掉,變空白 +plt.plot(xList, yList) +``` + +## XY軸標籤 +```python +plt.xlabel( + 'Focus setting', # 標籤 + fontsize=15, # 字型大小 + labelpad=10, # 標籤留白 + color='red', # 文字顏色 + rotation=90, # 文字旋轉角度 + fontweight='bold', # 粗體 +) +``` + +## 不要顯示軸的刻線 +```python +plt.gca().axes.get_xaxis().set_visible(False) +``` + +## 畫2條線 +```python +plt.plot(x, y1, label='sine curve',color='b') +plt.plot(x, y2, label='cosine curve',color='r') +``` + +## 畫大圖 +```python +figure(figsize=(12, 9), dpi=120) +``` +`12`跟`9`指的是英吋,`dpi`是每英吋幾個點,所以就是`12*120`跟`9*120`,也就是`1440x1080`。 + +## 存檔 +```python +plt.savefig(f'plot_{folder}.png') +``` + +## 註記(annotation) +```python +ax = plt.gca() +ax.annotate( + 'local max', # 註記文字 + xy=(xmax, ymax), # 點的座標 + xytext=(xmax, ymax + 5), # 文字的座標 + arrowprops=dict( # 箭頭的屬性 + facecolor='black', # 顏色:黑色 + shrink=0.05), # +) +``` +官方說明:[matplotlib.axes.Axes.annotate — Matplotlib 3.7.1](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.annotate.html) \ No newline at end of file diff --git a/04. Programming/Python/tkinter.md b/04. Programming/Python/tkinter.md index 2d5d15e..f97d8c5 100644 --- a/04. Programming/Python/tkinter.md +++ b/04. Programming/Python/tkinter.md @@ -1,4 +1,4 @@ -### 把matplotlib包裝成獨立視窗 +### 把[[matplotlib]]包裝成獨立視窗 ```python class Plot2D(Frame): def __init__(self, parent, dataCollector, **kwargs):