python画图
来源:互联网 发布:淘宝参数是什么意思 编辑:程序博客网 时间:2024/05/21 13:57
python下面画图的包是matplotlib(http://matplotlib.org/),想要运行这个包,一般都要安装Numpy和Scipy包。
安装好,具体执行的时候,可能还需安装setuptools包、dateutil包和pyparsing包,这些包如何安装只要google就可以。
下面是一个画图的具体例子。
from pylab import *import matplotlib.pyplot as plt# import matplotlib.font_manager as fmpv = [11123, 11360, 11616, 11677, 10055, 10266, 11285, 11067, 10594, 10301, 9699, 9073, 9519, 9301, 8840, 8200, 6851, 7784, 7281, 7770, 8139, 8289, 8388, 9321, 10661, 11248, 10619, 11545, 11246, 11398, 11729]uv = [403, 400, 406, 405, 367, 364, 398, 397, 387, 383, 374, 345, 354, 350, 338, 317, 279, 279, 267, 277, 287, 297, 308, 330, 370, 376, 360, 398, 399, 404, 415]fs = 16plt.figure(1)l1 = plt.subplot(211)plt.plot(pv, '-og', linewidth = 2, label = 'PV')plt.xlabel('View days', fontsize = fs)plt.ylabel('# Page Views', fontsize = fs)plt.title('PV', fontsize = fs)plt.grid(True)legend(loc = 5)# xlabel fontsizefor label in l1.xaxis.get_ticklabels(): label.set_fontsize(fs)for label in l1.yaxis.get_ticklabels(): label.set_fontsize(fs)l2 = plt.subplot(212)plt.plot(uv, '-or', linewidth = 2, label = 'UV')plt.xlabel('View days', fontsize = fs)plt.ylabel('# Unique Visitors', fontsize = fs)plt.title('UV', fontsize = fs)plt.grid(True)legend(loc = 5)for label in l2.xaxis.get_ticklabels(): label.set_fontsize(fs)for label in l2.yaxis.get_ticklabels(): label.set_fontsize(fs)plt.show()
画图的结果是:
另一个例子:
import matplotlib.pyplot as pltk1 = 5L1 = 100p = arange(0, 1, 0.01)y1 = 1 - ((1 - p**k1)**L1)plt.plot(p, y1, 'b', label = 'k=5,L=100')plt.hold(True)k2 = 10L2 = 1000y2 = 1 - ((1 - p**k2)**L2)plt.plot(p,y2, 'r', label = 'k=10,L=1000')plt.xlim(-0.1, 1.1)plt.ylim(-0.1, 1.1)plt.grid(True)plt.xlabel('Similarity')plt.ylabel('Collision probability')legend(loc=5)plt.show()
画图结果是:
0 0
- python 画图
- Python 画图
- Python画图
- python画图
- python画图
- Python 画图
- python画图
- Python 画图
- python 画图
- python 画图
- python画图
- Python 画图
- python画图
- python画图
- Python 画图
- Python画图
- python画图
- python画图
- 第五周作业--有向图邻接表表示及反向图构造
- 设计模式之解释器
- 大数相加
- delphi多线程编程
- javascrip引用类型object
- python画图
- linux系统中./configure --prefix 命令是什么意思?
- iOS越狱机子 进程间通讯
- 【LeetCode】Container With Most Water
- 交互设计学习day1 之三 工作流程说明
- Linux操作系统实验教程 费翔林主编 第二章 实验3 答案
- 过TesSafe反WinDbg双机调试
- SEO高级优化【PHP】-1
- 数据库 的版本为 661,无法打开。此服务器支持 655 版及更低版本。不支持降级路径