Python画离散点图的基础代码是什么,可以如何优化
Admin 2022-09-08 群英技术资讯 678 次浏览
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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
Python内置函数-compile() 函数,compile() 函数将一个字符串编译为字节代码。
这篇文章主要介绍了Python标准库time使用方式详解,文章围绕主题展开详细的内容介绍,具有一定的参考价值,需要的朋友可以参考一下
这篇文章主要为大家介绍了pytest官方文档解读fixtures的调用方式,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
这篇文章给大家分享的是有关用python读取mtx文件的内容,其实无论读取mtx文件还是其他格式的文件,都并不困难,接下来一起跟随小编学习一下吧。
内容介绍supervisor介绍安装supervisor设置环境变量配置supervisor管理一个进程supervisor配置文件详解启动supervisor有时候kill进程之后需要释放连接web
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008