python matplotlib
程序员文章站
2022-03-09 19:49:02
...
简单的画图,这里就直接贴代码了,以后画图可以用这个当做模板来看。
#!/usr/bin/env python
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
import pylab as pl
x_1 = [ 0.001264, 0.001324, 0.001385, 0.001565, 0.001565, 0.001746, 0.001746, 0.001806, 0.001987, 0.001987, 0.001987, 0.002107, 0.002107, 0.002107, 0.002167, 0.002227, 0.002288, 0.002348, 0.002408, 0.002589, 0.002649, 0.002709, 0.002769, 0.002829, 0.002829, 0.00289, 0.00301, 0.00307, 0.00307 ]
y_1 = [ 0.361357, 0.337021, 0.318584, 0.298673, 0.283923, 0.269912, 0.263274, 0.252212, 0.244838, 0.240413, 0.234513, 0.221239, 0.216077, 0.212389, 0.20649, 0.20354, 0.199853, 0.196903, 0.19174, 0.187316, 0.185841, 0.185103, 0.182153, 0.179941, 0.178466, 0.176254, 0.173304, 0.172566, 0.170354]
for i in range(len(x_1)):
x_1[i] = x_1[i] * 100.0
for i in range(len(y_1)):
y_1[i] = y_1[i] * 100.0
x_2 = [ 0.002889, 0.00295, 0.00301, 0.00307, 0.00313, 0.00313, 0.00319, 0.00319, 0.00319, 0.00319, 0.00319, 0.003251, 0.003251, 0.003251, 0.003251, 0.003251, 0.003251, 0.003251, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003311, 0.003371]
y_2 = [ 0.240413, 0.238201, 0.224189, 0.221239, 0.216814, 0.213127, 0.212389, 0.207965, 0.205752, 0.202802, 0.201327, 0.20059, 0.199115, 0.196903, 0.193215, 0.19174, 0.190265, 0.189528, 0.188791, 0.188053, 0.185841, 0.185103, 0.183628, 0.182153, 0.181416, 0.180678, 0.179204, 0.178466, 0.177729, 0.176254, 0.175516, 0.171829, 0.171829 ]
for i in range(len(x_2)):
x_2[i] = x_2[i] * 100.0
for i in range(len(y_2)):
y_2[i] = y_2[i] * 100.0
# attention the comma
plot1, = pl.plot(x_1, y_1, 'r')
plot2, = pl.plot(x_2, y_2, 'b')
pl.title('Curve')
pl.ylabel('miss probability [in %]')
pl.xlabel('false alarm [in %]')
pl.xlim(0.0, 0.4)
pl.ylim(0, 40)
pl.legend([plot1, plot2], ['line1', 'line2'], loc = 'best')
pl.show()
sys.exit(0)
上一篇: 【模板】快速幂||取余运算
下一篇: C++ 回文字符串判断