import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import numpy as np
x = np.array( [0,1,2,3,4,5,6,7,8,9] )
y = np.array( [10,11,12,13,4,5,6,7,8,9] )
plt.plot(x,y,”r-o”)
#red紅色 線型- marker:o
yMinIdx = np.argmin(y)
minY= y [yMinIdx]
#print(yMinIdx)
#print(y[yMinIdx] )
yMaxIdx = np.argmax(y)
maxY= y [yMaxIdx]
#print(yMaxIdx)
#print(y[yMaxIdx] )
plt.plot( [x[0], x[yMinIdx]],[minY,minY],”b–s”)
#plt.plot(x[0],y[yMinIdx],”bs”)
plt.plot( [x[0],x[yMaxIdx]],[maxY,maxY],”b–s”)
#plt.plot(x[0],y[yMaxIdx],”bs”)
annot_min = “(%3.1f,%3.1f)” %(yMinIdx,minY)
annot_max = “(%3.1f,%3.1f)” %(yMaxIdx,maxY)
plt.annotate(annot_min,(yMinIdx,minY))
plt.annotate(annot_max,(yMaxIdx,maxY))
繪出結果:
通用屬性:
linestyle:
圖例 legend
set_title()、set_xlabel()、set_ylabel()
ax.grid(visible=None, axis=’both’, …)
ax.set_xticks()
ax.set_yticks()
ax.annotate(text,xy,…)
推薦hahow線上學習python: https://igrape.net/30afN