python 离散点图画法的实现

作者:心之所向521 时间:2021-04-14 17:00:31 

基础代码

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()

python 离散点图画法的实现

离散图画法如上所示。

改进

python 离散点图画法的实现

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()

再次改进:

python 离散点图画法的实现

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()

又次改进:

python 离散点图画法的实现

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()

改进:----加准确率

python 离散点图画法的实现

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()

来源:https://blog.csdn.net/weixin_45564943/article/details/123880105

标签:python,离散点图
0
投稿

猜你喜欢

  • 使用JavaScript实现旋转的彩圈特效

    2023-08-22 16:34:53
  • [ASP]提高数据显示效率--缓存探幽

    2008-05-18 13:51:00
  • 6款jQuery图表插件[译]

    2009-06-01 10:34:00
  • 实用301转向到另一域名相应页面的asp代码

    2011-04-18 10:42:00
  • Python使用内置json模块解析json格式数据的方法

    2023-07-30 14:10:45
  • Python实现平行坐标图的两种方法小结

    2023-07-30 20:45:34
  • thinkphp控制器调度使用示例

    2023-11-16 12:34:15
  • 关于WARNING:Ignoring invalid distribution -pencv-python....警告信息的处理方法(已解决!)

    2021-01-14 18:14:28
  • JavaScript动态调整图片尺寸

    2009-11-23 12:20:00
  • 应用技术:如何通过SQLyog分析MySQL数据库

    2009-03-25 16:53:00
  • 详解Python如何实现尾递归优化

    2023-11-13 04:20:06
  • Mysql Innodb 引擎优化

    2010-10-25 20:01:00
  • python中super()函数的理解与基本使用

    2023-07-02 08:00:33
  • 详解Python中for循环的使用

    2023-06-13 13:55:40
  • ASP 隐藏下载地址及防盗链代码

    2011-02-26 11:17:00
  • python3使用pyqt5制作一个超简单浏览器的实例

    2023-04-12 19:44:51
  • 基于Python制作flappybird游戏的详细步骤

    2023-07-29 10:08:29
  • Django压缩静态文件的实现方法详析

    2023-06-15 05:31:33
  • ajax代理程序,自动判断字符编码

    2007-11-04 13:17:00
  • selenium+python自动化测试环境搭建步骤

    2021-03-16 02:34:34
  • asp之家 网络编程 m.aspxhome.com