1、软件版本
- anaconda python3.7.3
- pycharm 2019.2.3 学生教育版
2、python环境
3、代码示例说明
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.font_manager as fm
from matplotlib.ticker import FuncFormatter
plt.rcParams['font.sans-serif'] = ['Simsun']
plt.rcParams['axes.unicode_minus'] = False
snr = np.array([-3, -1, 1, 3, 5, 7, 9, 11])
timing1 = np.array([98.66, 99.49, 99.84, 99.97, 99.97, 99.98, 100, 100])/100
timing2 = np.array([99.62, 99.82, 99.97, 100, 99.99, 100, 100, 100])/100
timing3 = np.array([99.62, 99.87, 99.95, 99.98, 100, 100, 100, 100])/100
timing4 = np.array([99.61, 99.88, 99.92, 99.98, 100, 100, 100, 100])/100
timing5 = np.array([99.61, 99.88, 99.92, 99.98, 100, 100, 100, 100])/100
plt.plot(snr, timing1, 'rs-', snr, timing2, 'kx-', snr, timing3, 'k+-', /
snr, timing4, 'ko-', snr, timing5, 'k*-')
plt.xlabel('SNR/dB', fontproperties='times new roman', size=12)
plt.ylabel('定时正确率', size=12)
plt.xlim(-3, 11)
plt.xticks(snr, fontproperties='times new roman', size=10)
plt.yticks(fontproperties='times new roman', size=10)
def to_percent(temp, position):
return '%1.2f'%(100*temp) + '%'
plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))
plt.legend(labels=['浮点', '定点二十', '定点廿四', '定点廿八', '定点卅二'])
plt.grid(True)
plt.savefig('timing', dpi=96)
plt.show()

4、参考内容
微信公众号:通信随笔XIDIAN
