• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python利用matplotlib库绘制饼图的方法示例

python利用matplotlib库绘制饼图的方法示例

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python安装matplotlib,python matplotlib,python中matplotlib,python3 matplotlib,python3.5 matplotlib等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

介绍

matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。而且也可以方便地将它作为绘图控件,嵌入GUI应用程序中。

它的文档相当完备,并且 Gallery页面 中有上百幅缩略图,打开之后都有源程序。因此如果你需要绘制某种类型的图,只需要在这个页面中浏览/复制/粘贴一下,基本上都能搞定。

matplotlib的安装方法可以点击这里

这篇文章给大家主要介绍了python用matplotlib绘制饼图的方法,话不多说,下面来看代码。

示例代码

import matplotlib.pyplot as plt

# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
  autopct='%1.1f%%', shadow=True, startangle=90)

# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')


plt.savefig('D:\\pie.png')
plt.show()
</div>

结果

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

</div>

您可能想查找下面的文章:

  • python使用matplotlib绘制柱状图教程
  • python使用matplotlib绘制折线图教程
  • python利用matplotlib库绘制饼图的方法示例
  • Windows下为Python安装Matplotlib模块
  • Python使用matplotlib实现在坐标系中画一个矩形的方法
  • Python使用matplotlib绘制动画的方法
  • Python实现在matplotlib中两个坐标轴之间画一条直线光标的方法
  • Python Matplotlib库入门指南
  • Python中的Matplotlib模块入门教程
  • python的绘图工具matplotlib使用实例

相关文章

  • python 控制语句
  • 使用Python装饰器在Django框架下去除冗余代码的教程
  • Python中文分词实现方法(安装pymmseg)
  • Python字符串详细介绍
  • python备份文件的脚本
  • python实现查找excel里某一列重复数据并且剔除后打印的方法
  • 栈和队列数据结构的基本概念及其相关的Python实现
  • 精确查找PHP WEBSHELL木马的方法(1)
  • python选择排序算法实例总结
  • python获取一组数据里最大值max函数用法实例

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python+Opencv识别两张相似图片
    • Python构造函数及解构函数介绍
    • Python字符转换
    • 使用wxpython实现的一个简单图片浏览器实例
    • 浅析Python基础-流程控制
    • python中self原理实例分析
    • Python标准库之多进程(multiprocessing包)介绍
    • Python函数式编程指南(二):从函数开始
    • 深入解析Python中的上下文管理器
    • python实现文本文件合并

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有