python 离散点图画法的实现
更新时间:2022年04月01日 10:33:55 作者:心之所向521
本文主要介绍了python 离散点图画法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
基础代码
pred_y = test_output.data.numpy() pred_y = pred_y.flatten() print(pred_y, 'prediction number') print(test_y[:355].numpy(), 'real number') import matplotlib.pyplot as plt plt.rc("font", family='KaiTi') plt.figure() f, axes = plt.subplots(1, 1) x = np.arange(1, 356) # axes.plot(x , pred_y) axes.scatter(x,pred_y, c='r', marker = 'o') plt.axhline(36.7, c ='g') axes.set_xlabel("位置点位") axes.set_ylabel("预测值") axes.set_title("矫正网络结果") plt.savefig("result.png") plt.show()
离散图画法如上所示。
改进
import matplotlib.pyplot as plt plt.rc("font", family='KaiTi') plt.figure() f, axes = plt.subplots(1, 1) x = np.arange(1, 356) # axes.plot(x , pred_y) axes.scatter(x, pred_y, c='r', marker = 'o') plt.axhline(36.7, c ='g') axes.set_xlabel("位置点位") axes.set_ylabel("预测值") axes.set_title("矫正网络预测结果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.show()
再次改进:
import matplotlib.pyplot as plt plt.rc("font", family='KaiTi') plt.figure() f, axes = plt.subplots(1, 1) x = np.arange(1, 356) # axes.plot(x , pred_y) axes.scatter(x, pred_y, c='r', marker = 'o') plt.axhline(36.7, c ='g') axes.set_xlabel("位置点位") axes.set_ylabel("预测值") axes.set_title("矫正网络预测结果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.legend(['real', 'predict'], loc='upper left') plt.show()
又次改进:
import matplotlib.pyplot as plt plt.rc("font", family='KaiTi') plt.figure() f, axes = plt.subplots(1, 1) x = np.arange(1, 356) # axes.plot(x , pred_y) axes.scatter(x, pred_y, c='r', s=3, marker = 'o') plt.axhline(36.7, c ='g') axes.set_xlabel("位置点位") axes.set_ylabel("预测值") axes.set_title("矫正网络预测结果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.legend(['真实值36.7℃', '预测值'], loc='upper left') plt.show()
改进:----加准确率
import matplotlib.pyplot as plt plt.rc("font", family='KaiTi') plt.figure() f, axes = plt.subplots(1, 1) x = np.arange(1, 356) # axes.plot(x , pred_y) axes.scatter(x, pred_y, c='r', s=3, marker = 'o') plt.axhline(36.7, c ='g') axes.set_xlabel("位置点位") axes.set_ylabel("预测值") axes.set_title("矫正网络预测结果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.legend(['真实值36.7℃', '预测值'], loc='upper left') row_labels = ['准确率:'] col_labels = ['数值'] table_vals = [['{:.2f}%'.format(v*100)]] row_colors = ['gold'] my_table = plt.table(cellText=table_vals, colWidths=[0.1] * 5, rowLabels=row_labels, rowColours=row_colors, loc='best') plt.show()
到此这篇关于python 离散点图画法的文章就介绍到这了,更多相关python 离散点图内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
WIndows10系统下面安装Anaconda、Pycharm及Pytorch环境全过程(NVIDIA GPU版本)
这篇文章主要给大家介绍了关于WIndows10系统下面安装Anaconda、Pycharm及Pytorch环境(NVIDIA GPU版本)的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下2023-02-02基于python3.7利用Motor来异步读写Mongodb提高效率(推荐)
Motor是一个异步mongodb driver,支持异步读写mongodb。它通常用在基于Tornado的异步web服务器中。这篇文章主要介绍了基于python3.7利用Motor来异步读写Mongodb提高效率,需要的朋友可以参考下2020-04-04pytorch中的weight-initilzation用法
这篇文章主要介绍了pytorch中的weight-initilzation用法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-06-06
最新评论