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

Python画图学习入门教程

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

通过本文主要向大家介绍了Python画图学习入门教程等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了Python画图的基本方法。分享给大家供大家参考,具体如下:

Python:使用matplotlib绘制图表

python绘制图表的方法,有个强大的类库matplotlib,可以制作出高质量的2D和3D图形,先记录一下,以后慢慢学习。

matplotlib下载及API手册地址:http://sourceforge.net/projects/matplotlib/files/matplotlib/

数学库numpy下载及API手册地址:http://www.scipy.org/Download

几个绘图的例子,来自API手册:

1、最简单的图:

代码:

#!/usr/bin/env python
import matplotlib.pyplot as plt
plt.plot([10, 20, 30])
plt.xlabel('tiems')
plt.ylabel('numbers')
plt.show()

</div>

2.饼图:

代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pylab import *
# make a square figure and axes
figure(1, figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
fracs = [15,30,45, 10]
explode=(0, 0.05, 0, 0)
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
title('Raining Hogs and Dogs', bbox={'facecolor':'0.8', 'pad':5})
savefig('D:\\pie.png')
show()

</div>

3、使用numpy库函数:

代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.0, 1.01, 0.01)
s = np.sin(2*2*np.pi*t)
plt.fill(t, s*np.exp(-5*t), 'r')
plt.grid(True)
#保存为PDF格式,也可保存为PNG等图形格式
plt.savefig('D:\\test.pdf')
plt.show()

</div>

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python编码操作技巧总结》、《Python图片操作技巧总结》、《Python数据结构与算法教程》、《Python Socket编程技巧总结》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》

希望本文所述对大家Python程序设计有所帮助。

</div>

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

相关文章

  • Python之日期与时间处理模块(date和datetime)
  • 简介Python的collections模块中defaultdict类型的用法
  • python中List的sort方法指南
  • 用Python写飞机大战游戏之pygame入门(4):获取鼠标的位置及运动
  • 复制粘贴功能的Python程序
  • python 切片和range()用法说明
  • 详解Python中__str__和__repr__方法的区别
  • python中常用检测字符串相关函数汇总
  • python使用clear方法清除字典内全部数据实例
  • python3中str(字符串)的使用教程

文章分类

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

最近更新的内容

    • 用Python输出一个杨辉三角的例子
    • 学习python之编写简单简单连接数据库并执行查询操作
    • Python统计日志中每个IP出现次数的方法
    • Unicode和Python的中文处理
    • Python实现简单的代理服务器
    • Python实现将DOC文档转换为PDF的方法
    • 使用Python的Tornado框架实现一个Web端图书展示页面
    • python根据路径导入模块的方法
    • 在Python中使用列表生成式的教程
    • Python操作Excel之xlsx文件

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

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