当前位置:   article > 正文

python画曲线图_曲线1-e

曲线1-e

python画曲线图

import numpy as np
import matplotlib.pyplot as plt
import re
from matplotlib.pyplot import MultipleLocator


input_txt = 'r3.txt'
x = []
y = []

f = open(input_txt)
i=0
for line in f:
    line = line.strip('\n')
    line = line.split(' ')
    line = " ".join(line)
    line = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]').sub(' ', line) 
    line = line.split(' ')
    #if i>10:
    x.append(int(line[0]))
    y.append(float(line[1]))
    i=i+1

f.close

plt.plot(x, y)
y_major_locator=MultipleLocator(10)
ax=plt.gca()
ax.xaxis.set_major_locator(y_major_locator)
plt.margins(0)
#plt.xlim(5,40)
#plt.xticks(np.arange(1, 150))

plt.xlabel("train step")
plt.ylabel("loss")
plt.tick_params(axis="both")
plt.rcParams['figure.figsize'] = (5.0, 5.0)
plt.show()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

import matplotlib.pyplot as plt
import re
from matplotlib.pyplot import MultipleLocator


input_txt1 = 'r1.txt'
input_txt2 = 'r2.txt'
input_txt3 = 'r3.txt'
x = []
y1 = []
y2 = []
y3 = []

f = open(input_txt1)
i=0
for line in f:
    line = line.strip('\n')
    line = line.split(' ')
    line = " ".join(line)
    line = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]').sub(' ', line) 
   
    line = line.split(' ')
    if i>5 and i<60 :
        x.append(int(line[0]))
        y1.append(float(line[1]))
    i=i+1

f.close

f = open(input_txt2)
i=0
for line in f:
    line = line.strip('\n')
    line = line.split(' ')
    line = " ".join(line)
    line = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]').sub(' ', line) 
   
    line = line.split(' ')
    if i>5 and i<60 :
        y2.append(float(line[1]))
    i=i+1

f.close

f = open(input_txt3)
i=0
for line in f:
    line = line.strip('\n')
    line = line.split(' ')
    line = " ".join(line)
    line = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]').sub(' ', line) 
   
    line = line.split(' ')
    if i>5 and i<60 :
        y3.append(float(line[1]))
    i=i+1

f.close
plt.rcParams['figure.figsize'] = (10.0, 5.0)
plt.plot(x,y1,'b-.',label='Dense-YOLOv4')
plt.plot(x,y2,'.b',label='YOLOv4')
plt.plot(x,y3,'',label='SEDense-YOLOv4')

plt.xlabel("train step")
plt.ylabel("loss")
plt.show()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/877799
推荐阅读
相关标签
  

闽ICP备14008679号