pie函数--Matplotlib
matplotlib.pyplot.pie
函数功能: Plot a pie chart.
绘制饼图
Make a pie chart of array x. The fractional area of each wedge is given by x/sum(x). If sum(x) < 1, then the values of x give the fractional area directly and the array will not be normalized. The resulting pie will have an empty wedge of size 1 - sum(x).
The wedges are plotted counterclockwise, by default starting from the x-axis.
绘制数组x的饼图,每个楔形的局部面积通过x/sum(x)x/sum(x)x/sum(x)计算得到。如果sum(x)sum(x)sum(x)小于1,x的值直接反应每部分楔形的面积,这时数组不会被标准化。产生的饼图会有大小为1−sum(x)1-sum(x)1−sum(x)的空楔形部分。
默认情况下楔形是从从x轴开始逆时针绘制的。
函数语法: pie(x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=0, radius=1, counterclock=True, wedgeprops=None, textprops=None, center=0, 0, frame=False, rotatelabels=False, *, normalize=None, data=None)
函数参数:
x: 1D array-like。The wedge sizes
x: 一维数据。决定楔形面积大小
explode: array-like, default: None。If not None, is a len(x) array which specifies the fraction of the radius with which to offset each wedge.
裂开:数组,默认值为空,默认情况下,各部分均不远离圆心。若非空,则为与x长度相同的数组,参数explodeexplodeexplode指定每个楔形距离圆心的距离是半径的多少比例
当参数explode=0.5explode=0.5explode=0.5,即每块区域都离圆心0.5倍的半径距离
当参数explode=0.5explode=0.5explode=0.5,即每块区域都离圆心0.1倍的半径距离
当参数explodeexplodeexplode,取值各不同,则即每块区域离圆心不同的距离
labels: list, default: None。A sequence of strings providing the labels for each wedge
标签:列表,默认值为None。是一系列字符串,提供每块楔形的标签
colors: array-like, default: None。A sequence of colors through which the pie chart will cycle. If None, will use the colors in the currently active cycle.
颜色:数组,默认为None。饼图将循环显示的一系列颜色。若为空,将使用当前活动周期中的颜色。
实践表明,颜色的个数不需要与x的长度一致,颜色会循环展示。
一种颜色展示
两种颜色展示
三种颜色展示
四种颜色展示
autopct: None or str or callable, default: None
If not None, is a string or function used to label the wedges with their numeric value. The label will be placed inside the wedge. If it is a format string, the label will be fmt % pct. If it is a function, it will be called.
数据百分比标注格式:取值为None,字符串,可调用对象,默认值为None。若非空,是用于标记楔形数值的字符串或者函数。标签会放在楔形内部。如果标签为格式字符串,其格式为fmtfmt%fmt,若是一个函数,将会被调用。
补充:
%f格式:
**%f:**不指定宽度,整数部分全部输出,并输出6个小数位。
%m.nf:最小输出宽度为m个字符,数值精度为n。若数字宽度小于m,则在整数前面补空格;若数字宽度大于m,则全部输出
f = 5.6
g=23566.652
# 默认情况,整数部分全部输出,小数部分6位
print('%f'%f)
# 指定最小输出m与数字精度n
print('%3.2f'%f)
print('%5.2f'%f)
print('%7.2f'%f)
# 数据位数超出m,完整输出
print('%5.2f'%g)
明显可以看出当最小宽度m变大时,数字在饼图中因为在前面补空格而向后退。
pctdistance: float, default: 0.6。 The ratio between the center of each pie slice and the start of the text generated by autopct. Ignored if autopct is None.
浮点型,默认0.6。反应每块扇形的中心(每个扇形的圆心位置)与参数autopctautopctautopct产生的数值之间的距离与半径的比例。若未设置参数autopctautopctautopct则该参数也不生效。
当参数pctdistance=0pctdistance=0pctdistance=0,参数autopctautopctautopct产生的数值在每块扇形的圆心位置
当参数pctdistance=0.6pctdistance=0.6pctdistance=0.6,参数autopctautopctautopct产生的数值距离每块扇形圆心0.6倍距离的地方
当参数pctdistance=1pctdistance=1pctdistance=1,参数autopctautopctautopct产生的数值恰好在每块扇形的边缘位置
shadow: bool, default: False。Draw a shadow beneath the pie
阴影:布尔型,默认值False:无阴影。绘制饼图的阴影
当参数shadow=Trueshadow=Trueshadow=True,结果展示如下:
- 尚不理解
- normalize: None or bool, default: None When True, always make a full pie by normalizing x so that sum(x) == 1. False makes a partial pie if sum(x) <= 1 and raises a ValueError for sum(x) >1.When None, defaults to True if sum(x) >= 1 and False if sum(x) <1.Please note that the previous default value of None is now deprecated, and the default will change to True in the next release. Please pass normalize=False explicitly if you want to draw a partial pie.
labeldistance: float or None, default: 1.1。 at which the pie labels are drawn. If set to None, label are not drawn, but are stored for use in legend()
标签距离:浮点型或者None,默认浮点型1.1。饼图标签的径向距离。若设置为None,标签不会被展示,但是可以展示在legend中
参数labeldistance=1labeldistance=1labeldistance=1
参数labeldistance=1.2labeldistance=1.2labeldistance=1.2
参数labeldistance=Nonelabeldistance=Nonelabeldistance=None,标签不展示
参数labeldistance=Nonelabeldistance=Nonelabeldistance=None,标签在图例中展示
若参数labeldistancelabeldistancelabeldistance使用默认值1.1,同时有legend,则展示一次标签,一次图例。
startangle: float, default: 0 degrees。 The angle by which the start of the pie is rotated, counterclockwise from the x-axis.
起始角:浮点型,默认值是0°,起始饼旋转的角度,从x轴逆时针旋转。
radius: float, default: 1。The radius of the pie.
半径:浮点型,默认长度为1。饼的半径
参数radius=1.5radius=1.5radius=1.5,此图明显变大。
counterclock: bool, default: True。Specify fractions direction, clockwise or counterclockwise.
是否逆时针绘图:布尔型,默认值为True逆时针。指定绘制图形的顺时针与逆时针
参数conuterclock=Falseconuterclock=Falseconuterclock=False,顺时针绘图。
wedgeprops: dict, default: None
Dict of arguments passed to the wedge objects making the pie. For example, you can pass in wedgeprops = {‘linewidth’: 3} to set the width of the wedge border lines equal to 3. For more details, look at the doc/arguments of the wedge object. By default clip_on=False.
楔形边界属性设置:字典类型,默认值None.字典参数传递给楔形对象来绘制饼图。例如:传递′linewidth′:3{'linewidth': 3}′linewidth′:3 来设置楔形边界线的宽度等于3。更多详细内容查看楔形对象的文档/参数。
textprops: dict, default: None
Dict of arguments to pass to the text objects.
文本属性:字典属性,默认值:None
传递给文本对象的参数字典
center: (float, float), default: (0, 0)
The coordinates of the center of the chart.
中心:一对浮点型坐标,默认位置:(0,0)
图标中的坐标
设置参数center=(6,6)center=(6,6)center=(6,6)饼状图圆心在(-6,-6)位置,因为鼠标点的时候没有精确定位,所以显示的数值有一点偏差
参数centercentercenter为空,默认在(0,0)位置
frame: bool, default: False
Plot axes frame with the chart if true.
框架:布尔型,默认False:无框架
若为真,绘制图标的坐标系框架。
设置参数frame=Trueframe=Trueframe=True,绘制出来一个框架!这个框架的范围从(0,0)到(1,1)
rotatelabels: bool, default: False
Rotate each label to the angle of the corresponding slice if true.
旋转标签文本:布尔型,默认值False:不旋转
若为真,将标签旋转到相应角度
参数rotatelabels=30rotatelabels=30rotatelabels=30
官方文档:链接 https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html
pie函数--Matplotlib相关推荐
- Matplotlib——饼图pie()函数
饼图(扇形图)是一种常见的可以表示离散变量各水平占比情况的一种统计图.Matpllotlib提供了pie()函数用于绘制饼图. import matplotlib.pyplot as plt_ = p ...
- python绘制饼状图 标题_Python使用matplotlib的pie函数绘制饼状图功能示例
本文实例讲述了Python使用matplotlib的pie函数绘制饼状图功能.分享给大家供大家参考,具体如下: #coding=utf8 import matplotlib as mpl import ...
- python pie函数_matplotlib 知识点11:绘制饼图(pie 函数精讲)
饼图英文学名为Sector Graph,又名Pie Graph.常用于统计学模块. 画饼图用到的方法为:matplotlib.pyplot.pie( ) #!/usr/bin/env python#! ...
- python使用pie()函数绘制饼图
目录 1.pie()函数概述 2.pie()函数参数详解 3.pie()函数用法举例 4.pie()函数绘制饼图效果: 1.pie()函数概述 pie()函数用于绘制饼图.如下为pie()函数参数演示 ...
- R语言使用pie函数可视化饼图(pie chart)、为饼图添加百分比信息、使用plotrix包可视化3D饼图、使用plotrix包可视化扇形饼图
R语言使用pie函数可视化饼图(pie chart).为饼图添加百分比信息.使用plotrix包可视化3D饼图.使用plotrix包可视化扇形饼图 目录
- 魔法函数%matplotlib 解决matplotlib画图在Jupter/IPython中不显示
用Python画图时,有时候画图结果存储在内存中不显示,如下图 import seaborn as sns subset = tz_counts[:10] sns.barplot(y=subset.i ...
- 【MATLAB】进阶绘图 ( Pie Chart 饼图 | pie 函数 | 三维饼图 | pie3 函数 )
文章目录 一.Pie Chart 饼图 1.pie 函数 2.pie3 函数 3.饼图示例 一.Pie Chart 饼图 1.pie 函数 pie 函数文档 : https://ww2.mathwor ...
- R语言使用:符号生成向量数据、使用pie函数可视化饼图、自定义设置饼图色彩为彩虹色、使用box函数在当前图上加个方框
R语言使用:符号生成向量数据.使用pie函数可视化饼图.自定义设置饼图色彩为彩虹色.使用box函数在当前图上加个方框 目录 R语言使用:符号生成向量数据.使用pie函数可视化饼图.自定义设置饼图色彩为 ...
- 数据可视化之matplotlib实战:plt.pie()函数 绘制饼状图
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np# 防止乱码 mpl.rcParams[" ...
- subplots_adjust()函数--matplotlib
1. 函数功能 调整子区的展现效果 2. 函数语法 subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, ...
最新文章
- 自动驾驶软件工程之局部规划
- Oracle之数据操作__分组统计查询
- python使用方法-Python的使用方法
- 简约而不简单|值得收藏的Numpy小抄表(含主要语法、代码)
- flask-sqlalchemy mysql_Flask SQLAlchemy连接到MySQL数据库
- 小程序开发(3)-之wx.request封装
- gson json转map_Java 中几种常用 JSON 库性能比较
- linux c 多线程终止耗时长的任务,Linux C:从main()返回是否导致多线程应用程序终止?...
- FPGA与DSP区别
- inventor软件绘制百叶窗方法_三维工厂设计该使用什么软件?
- linux 基础学习之常用命令
- linux6磁盘绑定,关于Linux 6使用udev绑定共享磁盘的测试
- 因社会不公大学生找不到工作
- 如何不下载百度网盘下载资源
- endnotex7怎么导入中文文献_EndNote导入CNKI文献的方法 | 科研动力
- AForge处理视频和拍照(暂时没有音频)
- 如何把多个pdf文件合并成一个?
- 十六进制转float
- 百度媒体云-android接入教程,帮助文档首页/百度账号连接/百度账号接入指南 - 百度开放云平台...
- 薛定谔 | 分子对接及基于受体的虚拟筛选
热门文章
- unity button 通过事件改变物体颜色
- Atitit mybatis3 注解模式使用总结 目录 1. mybatisdemo	1 1.1. /ormMybatis3demo/src/db.properties	1 1.2. /ormMyb
- Atitit 移动互联网 技术维度 1. 1.3 移动互联网网络技术13	1 2. 第2章 移动终端53 手机 平板	2 3. 移动操作系统67	2 4. 移动互联网应用技术99	2 5. 	3 6.
- Atitit 容器化技术之道 attilax著 1. 概念	1 1.1. 容器是应用服务器中位于组件和平台之间的接口集合。	1 1.2. 有时候也指集合的概念,里面可以存放不同对象	2 1.3. 、新
- Atitit 信息链(Information Chain)的概念理解 attilax总结
- 阿里云产品专家孟威:SLS 全景体验
- 《云网络:数字经济的连接》图书发布会将于7月16日在杭举行
- 从架构到代码:软件开发的七个新趋势 | 凌云时刻
- 400电话查询php,PHP 匹配电话,手机,400号码 函数 及正则。很管用。
- php 根目录怎么写,php – 如何重写根目录中的目录