import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
import scipy.io
import numpy as np
params={
'axes.labelsize': '35',#轴上字
'xtick.labelsize':'27',#轴图例
'ytick.labelsize':'27',#轴图例
'lines.linewidth':2 ,#线宽
'legend.fontsize': '27',#图例大小
'figure.figsize': '12, 9'# set figure size,长12,宽9
}
pylab.rcParams.update(params)#set figure parameter
#画图库更新#line_styles=['ro-','b^-','gs-','ro--','b^--','gs--']#set line style#We give the coordinate date directly to give an example.
x1 = [-20,-15,-10,-5,0,0,5,10,15,20]y1 = [0,0.04,0.1,0.21,0.39,0.74,0.78,0.80,0.82,0.85]
y2 = [0,0.014,0.03,0.16,0.37,0.78,0.81,0.83,0.86,0.92]
y3 = [0,0.001,0.02,0.14,0.34,0.77,0.82,0.85,0.90,0.96]
y4 = [0,0,0.02,0.12,0.32,0.77,0.83,0.87,0.93,0.98]
y5 = [0,0,0.02,0.11,0.32,0.77,0.82,0.90,0.95,1]
plt.plot(x1,y1,'bo-',label='m=2, p=10%',markersize=20) # in 'bo-', b is blue, o is O marker, - is solid line and so on
plt.plot(x1,y2,'gv-',label='m=4, p=10%',markersize=20)
plt.plot(x1,y3,'ys-',label='m=6, p=10%',markersize=20)
plt.plot(x1,y4,'ch-',label='m=8, p=10%',markersize=20)
plt.plot(x1,y5,'mD-',label='m=10, p=10%',markersize=20)fig1 = plt.figure(1)
axes = plt.subplot(111)
#代码没什么好说的,这里只说一下plt.subplot(111)这个函数。
#plt.subplot(111)和plt.subplot(1,1,1)是等价的。意思是将区域分成1行1列,当前画的是第一个图(排序由行至列)。
#plt.subplot(211)意思就是将区域分成2行1列,当前画的是第一个图(第一行,第一列)。以此类推,只要不超过10,逗号就可省去。#axes = plt.gca()
axes.set_xticks([-20,-15,-10,-5,0,5,10,15,20])
axes.set_yticks([0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0])
axes.grid(True)# add grid
plt.legend(loc="lower right")#set legend location
plt.ylabel('Percentage')# set ystick label
plt.xlabel('Difference')# set xstck label
plt.savefig('plot_test1.png',dpi = 1000,bbox_inches='tight')
plt.show()
【python|Python 画图,点线图】
文章图片
推荐阅读
- python|Python 画图,柱状图
- IT|Python开发学习之Python和Excel的数据实现互通
- machine|GridSearchCV调参方法
- PHP与Python有什么区别和不同()
- 发现几个好玩的游戏编程平台,与君共勉!
- 机器学习|Python实现词云舞
- python相关学习|用python批量修改图片名称!超级简单
- 大数据|超高分辨率显著目标检测,新颖高效的错层嫁接架构PGNet(CVPR2022)
- 编程语言大杂烩|Python批量改变图片名字