栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python matplotlib 画图

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python matplotlib 画图

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
import matplotlib.path as mpath

fig = plt.figure()
ax = fig.add_subplot(221, aspect='auto')#2*2的画布,放在第一个位置
ax.grid(True)  # 隐藏网格
ax.grid(False)
rc('mathtext', default='regular')

star = mpath.Path.unit_regular_star(6)  # 星型Path
circle = mpath.Path.unit_circle()  # 圆形Path
# 整合两个路径对象的点
verts = np.concatenate([circle.vertices, star.vertices[::-1, ...]])
# 整合两个路径对象点的类型
codes = np.concatenate([circle.codes, star.codes])
# 根据路径点和点的类型重新生成一个新的Path对象
cut_star = mpath.Path(verts, codes)  # 五角星

# rectangle = mpath.Path.unit_rectangle()  # 长方形Path
# circle = mpath.Path.unit_circle()  # 圆形Path
# # 整合两个路径对象的点
# rectangle_verts = np.concatenate([circle.vertices, rectangle.vertices[::-1, ...]])
# # 整合两个路径对象点的类型
# rectangle_codes = np.concatenate([circle.codes, rectangle.codes])
# # 根据路径点和点的类型重新生成一个新的Path对象
# rectangle_star = mpath.Path(rectangle_verts, rectangle_codes)  # 长方形

layer = ['1', '2', '3', '4']
print(layer)
AUC = [0.8624, 0.8838, 0.8859, 0.8881]
print(AUC)
Logloss = [0.2119, 0.2209, 0.2265, 0.2307]
print(Logloss)

ax.plot(layer, Logloss, '--r', marker=star, markersize=10, label='Logloss')
ax2 = ax.twinx()
ax2.plot(layer, AUC, '--b', marker=star, markersize=10, label='AUC')
ax.legend(loc="upper left")
ax.set_xlabel("number of layer")
ax.set_ylabel("Logloss")
ax2.set_ylabel("AUC")
ax2.set_ylim(0.86, 0.9)
ax.set_ylim(0.2, 0.24)
ax2.legend(loc=0)
plt.savefig('0.png')

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/649930.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号