Python
pyplot
2019.2.20 基本函数参数总结
plt.plot(x, y, [fmt], label=’ ', linewidth=[int] )
Eg. plt.plot(x ,y, ‘go–’,label=’ BUAA’, linewidth=3,markersize=12 )
Eg.plt.plot(x ,y, label=’ BAYI’)
plot(x,y,color=‘green’,marker=‘o’,linestyle=‘dashed’)
fmt=[color][marker][linestyle]
color
‘b’ | blue
‘g’ | green
‘r’ | red
‘c’ | cyan
‘m’ | magenta
‘y’ | yellow
‘k’ | black
‘w’ | white
marker
‘.’ | 点标记符
‘,’ | 像素标记符
‘o’ | 圆圈标记符
‘v’ | 倒三角标记符
‘^’ | 正三角标记符
‘<’ | 左三角标记符
‘>’ | 右三角标记符
‘1’ | 向下竹蜻蜓
‘2’ | 向上竹蜻蜓
‘3’ | 向左竹蜻蜓
‘4’ | 向右竹蜻蜓
‘s’ | 四边形标记符
‘p’ | 五边形标记符
‘*’ | 星型标记符
‘h’ | 六边形标记符
‘H’ | 六边形标记符
‘+’ | +标记符
‘x’ | x标记符
‘D’ | 菱形标记符
‘d’ | 菱形标记符
‘|’ | 竖线标记符
‘_’ | 横线标记符
linestyle
‘-’ | 实线
‘–’ | 划线
‘-.’ | 点划线
‘:’ | 虚线
2019.3.19 Errorbar
plt.plot(x,y)
plt.errorbar(x,y_meam,yerr=y_std)
import os
import glob
import matplotlib.pyplot as plt
import numpy as np
path=[]
path.append('./result/*, 1, 10.0]')
path.append('./result/*, 1, 40.0]')
path.append('./result/*, 1, 80.0]')
path.append('./result/*, 1, 100.0]')
total = []
name = []
files = []
plt.figure(figsize=(15,10))
plt.grid(True, linestyle = "-.", color = "k")
plt.title('Vth_mean=0.0064 Vth_std=0.0017', loc='left')
for i in range (len(path)):
a=[]
a1=[]
files = glob.glob(path[i])
for file in files:
count=[]
f=open(file, 'r') #ind[1] is direction/ ind[0] is the number of index
next(f)
next(f)
next(f)
n=0
for line in f:
if n==300: #modified
break
n+=1
count.append(n)
a1.append(float(str(line).split(" ")[3].strip()))
#observe a--
f.close()
a.append(a1)
a1=[] #ai is temporary list
name=str(file).split(",")[-1][:-1]
a_np=np.array(a)
a_mean=np.mean(a_np,axis=0)
a_std=np.std(a_np,axis=0)
num=np.linspace(0,299,300)
plt.errorbar(num, a_mean,yerr=a_std,label=name)
plt.ylabel('Accuracy (%)', size=14)
plt.xlabel('Epoch', size=14)
name=[]
plt.legend(loc='lower right', fontsize='large')
plt.ylim((0, 1.0))
#print(num)
#print(type(a_mean))
#print(a_mean)
plt.show()