1.4 KiB
1.4 KiB
基本折線圖
給2個list,一個 x,一個 y
plt.clf() # 把圖清掉,變空白
plt.plot(xList, yList)
XY軸標籤
plt.xlabel(
'Focus setting', # 標籤
fontsize=15, # 字型大小
labelpad=10, # 標籤留白
color='red', # 文字顏色
rotation=90, # 文字旋轉角度
fontweight='bold', # 粗體
)
不要顯示軸的刻線
plt.gca().axes.get_xaxis().set_visible(False)
畫2條線
plt.plot(x, y1, label='sine curve',color='b')
plt.plot(x, y2, label='cosine curve',color='r')
畫大圖
figure(figsize=(12, 9), dpi=120)
12跟9指的是英吋,dpi是每英吋幾個點,所以就是12*120跟9*120,也就是1440x1080。
存檔
plt.savefig(f'plot_{folder}.png')
註記(annotation)
ax = plt.gca()
ax.annotate(
'local max', # 註記文字
xy=(xmax, ymax), # 點的座標
xytext=(xmax, ymax + 5), # 文字的座標
arrowprops=dict( # 箭頭的屬性
facecolor='black', # 顏色:黑色
shrink=0.05), #
)