python绘制图像

柱状图

import os# 输入想要存储图像的路径
os.chdir('D:')import matplotlib.pyplot as plt
import numpy as np
# 改变绘图风格
import seaborn as snssns.set(color_codes=True)cell = ['gen7', 'xgspon', '3081GB', 'vettel', 'totalplay', 'other']
pvalue = [21, 20, 18, 13, 7, 34]width = 0.60
index = np.arange(len(cell))
p1 = np.arange(0, len(cell), 0.01)
p2 = 0.05 + p1 * 0q1 = np.arange(0, len(cell), 0.01)
q2 = 0.1 + p1 * 0figsize = (10, 8)  # 调整绘制图片的比例
plt.plot(p1, p2, color='red', label='5% significance level')  # 绘制直线
plt.plot(q1, q2, color='yellow', label='10% significance level')  # 绘制直线
# 若是不想显示直线,可以直接将上面两行注释掉
#plt.bar(index, pvalue, width, color="#87CEFA")  # 绘制柱状图
plt.bar(index, pvalue, width,color=['y','g','b', 'c', 'm', 'r','k','gold'])
# plt.xlabel('cell type') #x轴
plt.ylabel('bug num')  # y轴
plt.title('project and bug num show')  # 图像的名称
plt.xticks(index, cell, fontsize=10)  # 将横坐标用cell替换,fontsize用来调整字体的大小
plt.legend()  # 显示label
plt.show()
plt.savefig('test.png', dpi=400)  # 保存图像,dpi可以调整图像的像素大小

效果预览

import os# 输入想要存储图像的路径
os.chdir('D:')import matplotlib.pyplot as plt
import numpy as np
# 改变绘图风格
import seaborn as snssns.set(color_codes=True)cell = ['Viettel', 'LLA', 'Telmex', 'gen7', 'Claro', 'RDS&1835GRF']
pvalue = [43, 32, 55, 21, 28, 15]width = 0.60
index = np.arange(len(cell))
p1 = np.arange(0, len(cell), 0.01)
p2 = 0.05 + p1 * 0q1 = np.arange(0, len(cell), 0.01)
q2 = 0.1 + p1 * 0figsize = (10, 8)  # 调整绘制图片的比例
plt.plot(p1, p2, color='red', label='5% significance level')  # 绘制直线
plt.plot(q1, q2, color='yellow', label='10% significance level')  # 绘制直线
# 若是不想显示直线,可以直接将上面两行注释掉
#plt.bar(index, pvalue, width, color="#87CEFA")  # 绘制柱状图
plt.bar(index, pvalue, width,color=['y','g','b', 'c', 'm', 'r','k','gold'])
# plt.xlabel('cell type') #x轴
plt.ylabel('bug num')  # y轴
plt.title('project and occpuy time show')  # 图像的名称
plt.xticks(index, cell, fontsize=10)  # 将横坐标用cell替换,fontsize用来调整字体的大小
plt.legend()  # 显示label
plt.show()
plt.savefig('test.png', dpi=400)  # 保存图像,dpi可以调整图像的像素大小

import os# 输入想要存储图像的路径
os.chdir('D:')import matplotlib.pyplot as plt
import numpy as np
# 改变绘图风格
import seaborn as snssns.set(color_codes=True)cell = ['Viettel', 'LLA', 'Telmex', 'gen7', 'Claro', 'Totalplay_3081']
pvalue = [23, 32, 35, 28, 15, 20]width = 0.60
index = np.arange(len(cell))
p1 = np.arange(0, len(cell), 0.01)
p2 = 0.05 + p1 * 0q1 = np.arange(0, len(cell), 0.01)
q2 = 0.1 + p1 * 0figsize = (10, 8)  # 调整绘制图片的比例
plt.plot(p1, p2, color='red', label='5% significance level')  # 绘制直线
plt.plot(q1, q2, color='yellow', label='10% significance level')  # 绘制直线
# 若是不想显示直线,可以直接将上面两行注释掉
#plt.bar(index, pvalue, width, color="#87CEFA")  # 绘制柱状图
plt.bar(index, pvalue, width,color=['y','g','b', 'c', 'm', 'r','k','gold'])
# plt.xlabel('cell type') #x轴
plt.ylabel('bug num')  # y轴
plt.title('project and occpuy time show')  # 图像的名称
plt.xticks(index, cell, fontsize=10)  # 将横坐标用cell替换,fontsize用来调整字体的大小
plt.legend()  # 显示label
plt.show()
plt.savefig('test.png', dpi=400)  # 保存图像,dpi可以调整图像的像素大小

饼图

import matplotlib.pyplot as plt
from matplotlib.patches import ConnectionPatch
import numpy as np
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 5))
fig.subplots_adjust(wspace=0)
ratios = [.27, .56, .17]
labels = ['Factory', 'Bug', 'CE']
explode = [0.1, 0, 0]
angle = -180 * ratios[0]
ax1.pie(ratios, autopct='%1.1f%%', startangle=angle,labels=labels, explode=explode)
xpos = 0
bottom = 0
ratios = [.30, .50, .20]
width = .2
colors = [[.1, .3, .5], [.1, .3, .3], [.1, .3, .7], [.1, .3, .9]]
num1 = "factory tool"
num2 = "product SOP"
num3 = "maintence"
num = ["factory tool","product SOP","maintence"]
print(num[1])
for j in range(len(ratios)):height = ratios[j]ax2.bar(xpos, height, width, bottom=bottom, color=colors[j])ypos = bottom + ax2.patches[j].get_height() / 2bottom += heightax2.text(xpos, ypos, num[j],ha='center')
ax2.set_title('list')
#ax2.legend(('50-65', 'Over 65', '35-49', 'Under 35'))
ax2.axis('off')
ax2.set_xlim(- 2.5 * width, 2.5 * width)theta1, theta2 = ax1.patches[0].theta1, ax1.patches[0].theta2
center, r = ax1.patches[0].center, ax1.patches[0].r
bar_height = sum([item.get_height() for item in ax2.patches])
# draw top connecting line
x = r * np.cos(np.pi / 180 * theta2) + center[0]
y = r * np.sin(np.pi / 180 * theta2) + center[1]
con = ConnectionPatch(xyA=(-width / 2, bar_height), coordsA=ax2.transData,xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
con.set_linewidth(4)
ax2.add_artist(con)
# draw bottom connecting line
x = r * np.cos(np.pi / 180 * theta1) + center[0]
y = r * np.sin(np.pi / 180 * theta1) + center[1]
con = ConnectionPatch(xyA=(-width / 2, 0), coordsA=ax2.transData,xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
ax2.add_artist(con)
con.set_linewidth(4)
plt.show()
import matplotlib.pyplot as plt
from matplotlib.patches import ConnectionPatch
import numpy as np
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 5))
fig.subplots_adjust(wspace=0)
ratios = [.43, .45, .18]
labels = ['Telmex support', 'fixed Bug', 'write document']
explode = [0.1, 0, 0]
angle = -180 * ratios[0]
ax1.pie(ratios, autopct='%1.1f%%', startangle=angle,labels=labels, explode=explode)
xpos = 0
bottom = 0
ratios = [.30, .50, .20]
width = .2
colors = [[.1, .3, .5], [.1, .3, .3], [.1, .3, .7], [.1, .3, .9]]
num1 = "Documentation"
num2 = "Customer Field Test"
num3 = "identify the problem"
num = ["Documentation","Customer Field Test","identify the problem"]
print(num[1])
for j in range(len(ratios)):height = ratios[j]ax2.bar(xpos, height, width, bottom=bottom, color=colors[j])ypos = bottom + ax2.patches[j].get_height() / 2bottom += heightax2.text(xpos, ypos, num[j],ha='center')
ax2.set_title('list')
#ax2.legend(('50-65', 'Over 65', '35-49', 'Under 35'))
ax2.axis('off')
ax2.set_xlim(- 2.5 * width, 2.5 * width)theta1, theta2 = ax1.patches[0].theta1, ax1.patches[0].theta2
center, r = ax1.patches[0].center, ax1.patches[0].r
bar_height = sum([item.get_height() for item in ax2.patches])
# draw top connecting line
x = r * np.cos(np.pi / 180 * theta2) + center[0]
y = r * np.sin(np.pi / 180 * theta2) + center[1]
con = ConnectionPatch(xyA=(-width / 2, bar_height), coordsA=ax2.transData,xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
con.set_linewidth(4)
ax2.add_artist(con)
# draw bottom connecting line
x = r * np.cos(np.pi / 180 * theta1) + center[0]
y = r * np.sin(np.pi / 180 * theta1) + center[1]
con = ConnectionPatch(xyA=(-width / 2, 0), coordsA=ax2.transData,xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
ax2.add_artist(con)
con.set_linewidth(4)
plt.show()

bug分布饼图

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = 'simhei'
data = [16, 10, 9,4,4,15]
label = ['web issues', 'other(CWMP DHCP DNS FLASH VOIp VLAN)','olt issues','SDK issues','WAN/ipv6','wifi issues']
plt.pie(data, labels = label, autopct='%.2f%%')
plt.title('bug分布图')
plt.show()

雷达图

import numpy as np
import matplotlib.pyplot as plt
# 用于正常显示中文
plt.rcParams['font.sans-serif'] = 'SimHei'
#用于正常显示符号
plt.rcParams['axes.unicode_minus'] = False# 使用ggplot的绘图风格,这个类似于美化了,可以通过plt.style.available查看可选值,你会发现其它的风格真的丑。。。
plt.style.use('ggplot')# 构造数据
values = [2.6,2.1,3.4,3,4.1]
feature = ['个人能力','QC知识','解决问题能力','服务质量意识','团队精神']# 设置每个数据点的显示位置,在雷达图上用角度表示
angles=np.linspace(0, 2*np.pi,len(values), endpoint=False)# 拼接数据首尾,使图形中线条封闭
values=np.concatenate((values,[values[0]]))
angles=np.concatenate((angles,[angles[0]]))# 绘图
fig=plt.figure()
# 设置为极坐标格式
ax = fig.add_subplot(111, polar=True)
# 绘制折线图
ax.plot(angles, values, 'o-', linewidth=2)
# 填充颜色
ax.fill(angles, values, alpha=0.25)# 设置图标上的角度划分刻度,为每个数据点处添加标签
ax.set_thetagrids(angles * 180/np.pi, feature)# 设置雷达图的范围
ax.set_ylim(0,5)
# 添加标题
plt.title('活动前后员工状态表现')
# 添加网格线
ax.grid(True)plt.show()
import numpy as np
import matplotlib.pyplot as plt# 用于正常显示中文
#plt.rcParams['font.family'] = ['sans-serif']#如果是windows系统请去掉这行注释
#plt.rcParams['font.sans-serif'] = ['SimHei']#如果是windows系统请去掉这行注释plt.rcParams['font.sans-serif'] = 'SimHei'# 用于正常显示符号
plt.rcParams['axes.unicode_minus'] = Falseplt.style.use('ggplot')
# 使用ggplot的绘图风格
plt.style.use('ggplot')# 各个属性值
feature = ['语文', '数学', '英语', '物理', '化学', '生物']
value = np.array([95, 96, 98, 85, 79, 85])# 设置每个数据点的显示位置,在雷达图上用角度表示
angles = np.linspace(0, 2 * np.pi, len(feature), endpoint=False)
angles = np.concatenate((angles, [angles[0]]))
feature = np.concatenate((feature, [feature[0]]))
# 绘图
fig = plt.figure(facecolor='white')
subject_label = ['王康']
# 拼接数据首尾,使图形中线条封闭
values = np.concatenate((value, [value[0]]))
print(values)
# 设置为极坐标格式
ax = fig.add_subplot(111, polar=True)
# 绘制折线图
ax.plot(angles, values, 'o-', linewidth=1, label=subject_label[0])
# 填充颜色
ax.fill(angles, values, alpha=0.25)# 设置图标上的角度划分刻度,为每个数据点处添加标签
ax.set_thetagrids(angles * 180 / np.pi, feature)# 设置雷达图的范围
ax.set_ylim(0, 100)# 添加标题
plt.title('不同学生成绩分布雷达图')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=1, frameon=False)
# 添加网格线
ax.grid(True)
# 保存图片
# plt.savefig('雷达图.png')plt.show()
import numpy as np
import matplotlib.pyplot as plt# 用于正常显示中文
#plt.rcParams['font.family'] = ['sans-serif']#如果是windows系统请去掉这行注释
#plt.rcParams['font.sans-serif'] = ['SimHei']#如果是windows系统请去掉这行注释plt.rcParams['font.sans-serif'] = 'SimHei'# 用于正常显示符号
plt.rcParams['axes.unicode_minus'] = Falseplt.style.use('ggplot')
# 使用ggplot的绘图风格
plt.style.use('ggplot')# 各个属性值
feature = ['个人能力', '网通知识', '解决问题能力', '服务质量意识', '团队精神', '沟通能力']
value = np.array([80, 76, 86, 90, 79, 70])# 设置每个数据点的显示位置,在雷达图上用角度表示
angles = np.linspace(0, 2 * np.pi, len(feature), endpoint=False)
angles = np.concatenate((angles, [angles[0]]))
feature = np.concatenate((feature, [feature[0]]))
# 绘图
fig = plt.figure(facecolor='white')
subject_label = ['李勇']
# 拼接数据首尾,使图形中线条封闭
values = np.concatenate((value, [value[0]]))
print(values)
# 设置为极坐标格式
ax = fig.add_subplot(111, polar=True)
# 绘制折线图
ax.plot(angles, values, 'o-', linewidth=1, label=subject_label[0])
# 填充颜色
ax.fill(angles, values, alpha=0.25)# 设置图标上的角度划分刻度,为每个数据点处添加标签
ax.set_thetagrids(angles * 180 / np.pi, feature)# 设置雷达图的范围
ax.set_ylim(0, 100)# 添加标题
plt.title('能力分布图')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=1, frameon=False)
# 添加网格线
ax.grid(True)
# 保存图片
# plt.savefig('雷达图.png')plt.show()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/54995.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python基础知识(八)--文件操作,备份文件

文件可以用来存储数据。若根据文件内容的不同来给文件分类,可分为: (1)文本类型:存放文字类数据,读写时使用r、w; (2)二进制原始数据类型:存放二进制bytes数…

【GUI设计】基于图像分割的GUI系统(6),matlab实现

博主简介: 如需获取设计的完整源代码或者有matlab图像代码项目需求/合作,可联系主页个人简介提供的联系方式或者文末的二维码。博客内容有疑问可联系沟通(博主邮箱:3249726188qq.com)。 ~~~~~~~~~~~~~~~~~~~~~~~…

实现简易 vuedraggable 的拖拽排序功能

一、案例效果 拖拽计数4实现手动排序 二、案例代码 <draggable:list"searchResult.indicator":group"{ name: indicators }"item-key"field"handle".drag-handle-icon"><divclass"field-item"v-for"(item…

ubuntu如何开启和关闭图形界面

在Ubuntu中&#xff0c;你可以根据需要开启或关闭图形界面。以下是具体的方法&#xff1a; 关闭图形界面 方法一&#xff1a;使用 systemctl 命令 打开终端。输入以下命令切换到多用户目标&#xff08;相当于关闭图形界面&#xff09;&#xff1a;sudo systemctl set-defaul…

快速创建第一个Spring Boot 项目

一、介绍 Spring Boot 是一个开源的 Java 基础框架&#xff0c;它基于 Spring 框架&#xff0c;用于创建独立、生产级别的基于 Spring 的应用程序&#xff0c;你可以“跑起来”&#xff08;run&#xff09;你的 Spring 应用程序。Spring Boot 让基于 Spring 的应用开发变得更容…

对onlyoffice进行定制化开发

基于onlyoffice8.0源码&#xff0c;进行二次开发&#xff0c;可实现包括但不限于以下的功能 1、内容控件的插入 2、内容空间的批量替换 3、插入文本 4、插入图片 5、添加&#xff0c;去除水印 6、修改同时在线人数限制 7、内容域的删除 8、页面UI的定制化 9、新增插件开发 10、…

生信初学者教程(四):软件

文章目录 RRstudioLinux系统其他软件本书是使用R语言编写的教程,用户需要下载R和RStudio软件用于进行分析。 版权归生信学习者所有,禁止商业和盗版使用,侵权必究 R R语言是一种免费的统计计算和图形化编程语言,是一种用于数据分析和统计建模的强大工具。它具有丰富的统计…

关系型数据库和非关系型数据库的区别

1.常见的主流数据库 关系型数据库&#xff1a; MySql 、达梦 、PostgreSQL 、Oracle 、Sql Server 、Sqlite非关系型数据库&#xff1a; Redis 、MongoDB 、HBase 、 Neo4J 、 CouchDB 2.介绍 关系型数据库最典型的数据结构是表&#xff0c;由二维表及其之间的联系…

C 标准库 - <ctype.h>

C 标准库 - <ctype.h> 概述 <ctype.h> 是 C 语言标准库中的一个头文件,它提供了一系列用于测试和操作字符的函数。这些函数主要用于检查字符是否属于特定的字符类别,如字母、数字、标点符号等,以及进行字符的大小写转换。<ctype.h> 中的函数通常在处理文…

C语言 | Leetcode C语言题解之第429题N叉树的层序遍历

题目&#xff1a; 题解&#xff1a; #define MAX_LEVE_SIZE 1000 #define MAX_NODE_SIZE 10000int** levelOrder(struct Node* root, int* returnSize, int** returnColumnSizes) {int ** ans (int **)malloc(sizeof(int *) * MAX_LEVE_SIZE);*returnColumnSizes (int *)mal…

如何在 Linux 终端使用 GET 和 POST 请求

文章目录 1、GET请求基本请求带有请求头带有参数将响应保存成文件 2、POST请求基本请求发送JSON格式的POST请求体使用文件作为POST请求体使用时注意 1、GET请求 基本请求 在Linux中&#xff0c;发送GET请求通常使用 curl 命令&#xff0c;curl 的默认行为就是发送GET请求&…

ArcGIS Desktop使用入门(三)常用工具条——拓扑(下篇:地理数据库拓扑)

系列文章目录 ArcGIS Desktop使用入门&#xff08;一&#xff09;软件初认识 ArcGIS Desktop使用入门&#xff08;二&#xff09;常用工具条——标准工具 ArcGIS Desktop使用入门&#xff08;二&#xff09;常用工具条——编辑器 ArcGIS Desktop使用入门&#xff08;二&#x…

WordPress最佳恶意软件扫描插件:入门级指南

在现代互联网环境中&#xff0c;网站安全已经成为每个网站管理员必须重视的问题。特别是对于使用WordPress的用户来说&#xff0c;由于其普及度高&#xff0c;WordPress网站常常成为黑客的首要攻击目标。幸运的是&#xff0c;有许多优秀的恶意软件扫描插件可以帮助我们保护网站…

[附源码]网上订餐系统+SpringBoot+前后端分离

今天带来一款优秀的项目&#xff1a;网上订餐系统源码 。 系统采用的流行的前后端分离结构&#xff0c;包含了“管理端”&#xff0c;“商家管理端”&#xff0c;“用户购买端” 如果您有任何问题&#xff0c;也请联系小编&#xff0c;小编是经验丰富的程序员&#xff01; 一.…

[000-002-01].第29节:MySQL数据库缓冲池

1、什么是数据缓冲池&#xff1a; 1.InnoDB 存储引擎是以页为单位来管理存储空间的&#xff0c;我们进行的增删改查操作其实本质上都是在访问页面&#xff08;包括读页面、写页面、创建新页面等操作&#xff09;&#xff0c;而磁盘 I/O 需要消耗的时间很多&#xff0c;而在内存…

[leetcode]216_组合总和III_给定数字范围且输出无重复

找出所有相加之和为 n 的 k 个数的组合&#xff0c;且满足下列条件&#xff1a; 只使用数字1到9 每个数字 最多使用一次 返回 所有可能的有效组合的列表 。该列表不能包含相同的组合两次&#xff0c;组合可以以任何顺序返回。示例 1: 输入: k 3, n 7 输出: [[1,2,4]] 解释: 1…

dataclasses中asdict的用法

今天读源码读到这个函数的用法&#xff0c;它用在声明的dataclass类里面&#xff0c;将dataclass声明的属性变成字典返回。 有以下几点可能需要注意&#xff1a; 第一个是直接赋值的变量不会被asdict返回&#xff0c;只有声明的变量才行。 from dataclasses import asdict, …

【Python报错已解决】TypeError: tuple indices must be integers or slices, not str

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏: 《C干货基地》《粉丝福利》 ⛺️生活的理想&#xff0c;就是为了理想的生活! 专栏介绍 在软件开发和日常使用中&#xff0c;BUG是不可避免的。本专栏致力于为广大开发者和技术爱好者提供一个关于BUG解决的经…

重建大师区块划分的原则是什么?

根据计算机内存来进行划分&#xff0c;一般预估内存不超过计算机内存的2/3。 重建大师&#xff0c;这是一款专为超大规模实景三维数据生产设计的集群并行处理软件&#xff0c;支持卫星影像、航空影像、倾斜影像和激光点云多源数据输入建模&#xff0c;可完成超大规模数据的空三…

华为HarmonyOS灵活高效的消息推送服务(Push Kit) -- 7 推送卡片刷新消息

场景介绍 如今衣食住行娱乐影音应用占据了大多数人的手机&#xff0c;一部手机可以满足日常大多需求&#xff0c;但对需要经常查看或进行简单操作的应用来说&#xff0c;总需要用户点开应用体验较繁琐。针对此种场景&#xff0c;HarmonyOS提供了Form Kit&#xff08;卡片开发服…