Python画离散点图的基础代码是什么,可以如何优化
Admin 2022-09-08 群英技术资讯 763 次浏览
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()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了解决python3 json数据包含中文的读写问题,需要的朋友可以参考下
这篇文章主要为大家介绍了python神经网络Batch Normalization底层原理详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
最近遇到这样一个项目需求制作一个程序有一个简单的查询入口实现Excel的查询与生成,今天教大家利用Python制作本地Excel的查询与生成的程序,感兴趣的朋友跟随小编一起看看吧
今天小编就为大家分享一篇python 实现GUI(图形用户界面)编程详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
下面是Python3实现的旋转数组的3种算法。一、题目给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。例如:输入: [1,
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008