x = np.array([1, 2,3,4, 5,6, 7, 8,9,10,11,12,13,14,15,16,17])
y = [86.94,75.70,56.32,89.91,89.12,57.98,91.12,67.97,85.99,93.96,91.64,62.48,96.62,94.67,86.69,54.27,83.3]
x_smooth = np.linspace(x.min(),x.max(),300)
y_smooth1 = make_interp_spline(x, Reduce)(x_smooth)
plt.plot(x_smooth,y_smooth1,label='NS') #平滑曲线
plt.scatter(x, NS_re,marker='.') # 散点图
plt.legend(loc=3) # 让图例生效
plt.xticks(x, names) #rotation=1
plt.margins(0) # 控制两边是否有边界
plt.subplots_adjust(bottom=0.1)
pyplot.yticks([1])
plt.show()
# 如果要保存图片(此处是eps格式),保存的话最好注释掉上一行的plt.show():
plt.savefig('pic1.eps', format='eps', dpi=1000)
python用matplotlib绘制平滑曲线图及散点图
于 2022-04-10 14:15:59 首次发布