#-*- coding: utf-8 -*-
'''
subplot(m,n,p):其中,m表示是图排成m行,n表示图排成n列,也就是整个figure中有n个图是排成一行的,一共m行,如果m=2就是表示2行图。p表示图所在的位置,p=1表示从左到右从上到下的第一个位置。
np.random.uniform(0.5,1.0,n):获取 0.5~1.0之间n个随机数
zip(x,y):将x和Y中的数据两两配对最后以列表返回
plt.text(x+0.4, y+0.1, "%.2f"%y, ha="center"):指定文字出现在柱状图上的位置和内容
x+0.4:文字显示横向增加0.4长度
y+0.1:文字显示纵向增加0.1长度
"%.2f"%y:应该显示的内容
@author: soyo
'''
import matplotlib.pylab as plt
import numpy as np
plt.subplot(2,1,1)
n=12
x=np.arange(n)
print x
print x/float(n)
print np.random.uniform(0.5,1.0,n)
y1=(1-x/float(n))*np.random.uniform(0.5,1.0,n)
y2=(1-x/float(n))*np.random.uniform(0.5,1.0,n)
plt.bar(x,+y1,facecolor="red",edgecolor="grey")
plt.bar(x,-y2,facecolor="lightblue",edgecolor="orange")
print y1
for x,y in zip(x,y1):
plt.text(x+0.4, y+0.1, "%.2f"%y, ha="center")
print (x,y)
plt.ylim(-1.25,+1.25)
plt.subplot(2,2,3)
x=np.linspace(-np.pi,np.pi,300, endpoint=True)
print x
sin=np.sinc(x)
cos=np.cos(x)
plt.plot(x,cos,color="red",linewidth=2.7,linestyle="-")
plt.plot(x,sin,color="blue",linewidth=4,linestyle="--")
plt.xlim(x.min()*1.1,x.max()*1.1)
plt.xticks([-np.pi,-np.pi/2,0,np.pi/2,np.pi],[r'$-\pi$',r'$-\pi/2$',r'$0$',r'$+\pi/2$',r'$+\pi$'])
plt.ylim(cos.min()*1.1,cos.max()*1.1)
# plt.yticks([-1,0,1],[r'$-1$',r'$0$',r'$+1$'])
plt.yticks([-1,0,1]) plt.subplot(2,2,4)
m=10
z=np.random.uniform(5,9,6)
plt.pie(z)
plt.show()

结果:

[ 0  1  2  3  4  5  6  7  8  9 10 11]
[ 0. 0.08333333 0.16666667 0.25 0.33333333 0.41666667
0.5 0.58333333 0.66666667 0.75 0.83333333 0.91666667]
[ 0.95962168 0.83510776 0.59960879 0.9103227 0.86161055 0.85219339
0.64341482 0.50396784 0.79940237 0.78113541 0.66371799 0.63459297]
[ 0.65987664 0.87527832 0.79239077 0.61438775 0.44085434 0.38703261
0.40706581 0.2836271 0.25465063 0.20754596 0.124999 0.08099565]
(0, 0.65987664052659789)
(1, 0.87527832104794756)
(2, 0.79239077290271298)
(3, 0.61438775127130618)
(4, 0.44085434356099779)
(5, 0.3870326100974873)
(6, 0.40706580998264275)
(7, 0.2836271049672956)
(8, 0.2546506260468242)
(9, 0.20754596219057092)
(10, 0.12499900221786377)
(11, 0.080995646704109761)
[-3.14159265 -3.12057866 -3.09956466 -3.07855066 -3.05753666 -3.03652267
-3.01550867 -2.99449467 -2.97348067 -2.95246667 -2.93145268 -2.91043868
-2.88942468 -2.86841068 -2.84739669 -2.82638269 -2.80536869 -2.78435469
-2.7633407 -2.7423267 -2.7213127 -2.7002987 -2.6792847 -2.65827071
-2.63725671 -2.61624271 -2.59522871 -2.57421472 -2.55320072 -2.53218672
-2.51117272 -2.49015873 -2.46914473 -2.44813073 -2.42711673 -2.40610273
-2.38508874 -2.36407474 -2.34306074 -2.32204674 -2.30103275 -2.28001875
-2.25900475 -2.23799075 -2.21697676 -2.19596276 -2.17494876 -2.15393476
-2.13292076 -2.11190677 -2.09089277 -2.06987877 -2.04886477 -2.02785078
-2.00683678 -1.98582278 -1.96480878 -1.94379479 -1.92278079 -1.90176679
-1.88075279 -1.85973879 -1.8387248 -1.8177108 -1.7966968 -1.7756828
-1.75466881 -1.73365481 -1.71264081 -1.69162681 -1.67061282 -1.64959882
-1.62858482 -1.60757082 -1.58655683 -1.56554283 -1.54452883 -1.52351483
-1.50250083 -1.48148684 -1.46047284 -1.43945884 -1.41844484 -1.39743085
-1.37641685 -1.35540285 -1.33438885 -1.31337486 -1.29236086 -1.27134686
-1.25033286 -1.22931886 -1.20830487 -1.18729087 -1.16627687 -1.14526287
-1.12424888 -1.10323488 -1.08222088 -1.06120688 -1.04019289 -1.01917889
-0.99816489 -0.97715089 -0.95613689 -0.9351229 -0.9141089 -0.8930949
-0.8720809 -0.85106691 -0.83005291 -0.80903891 -0.78802491 -0.76701092
-0.74599692 -0.72498292 -0.70396892 -0.68295492 -0.66194093 -0.64092693
-0.61991293 -0.59889893 -0.57788494 -0.55687094 -0.53585694 -0.51484294
-0.49382895 -0.47281495 -0.45180095 -0.43078695 -0.40977295 -0.38875896
-0.36774496 -0.34673096 -0.32571696 -0.30470297 -0.28368897 -0.26267497
-0.24166097 -0.22064698 -0.19963298 -0.17861898 -0.15760498 -0.13659098
-0.11557699 -0.09456299 -0.07354899 -0.05253499 -0.031521 -0.010507
0.010507 0.031521 0.05253499 0.07354899 0.09456299 0.11557699
0.13659098 0.15760498 0.17861898 0.19963298 0.22064698 0.24166097
0.26267497 0.28368897 0.30470297 0.32571696 0.34673096 0.36774496
0.38875896 0.40977295 0.43078695 0.45180095 0.47281495 0.49382895
0.51484294 0.53585694 0.55687094 0.57788494 0.59889893 0.61991293
0.64092693 0.66194093 0.68295492 0.70396892 0.72498292 0.74599692
0.76701092 0.78802491 0.80903891 0.83005291 0.85106691 0.8720809
0.8930949 0.9141089 0.9351229 0.95613689 0.97715089 0.99816489
1.01917889 1.04019289 1.06120688 1.08222088 1.10323488 1.12424888
1.14526287 1.16627687 1.18729087 1.20830487 1.22931886 1.25033286
1.27134686 1.29236086 1.31337486 1.33438885 1.35540285 1.37641685
1.39743085 1.41844484 1.43945884 1.46047284 1.48148684 1.50250083
1.52351483 1.54452883 1.56554283 1.58655683 1.60757082 1.62858482
1.64959882 1.67061282 1.69162681 1.71264081 1.73365481 1.75466881
1.7756828 1.7966968 1.8177108 1.8387248 1.85973879 1.88075279
1.90176679 1.92278079 1.94379479 1.96480878 1.98582278 2.00683678
2.02785078 2.04886477 2.06987877 2.09089277 2.11190677 2.13292076
2.15393476 2.17494876 2.19596276 2.21697676 2.23799075 2.25900475
2.28001875 2.30103275 2.32204674 2.34306074 2.36407474 2.38508874
2.40610273 2.42711673 2.44813073 2.46914473 2.49015873 2.51117272
2.53218672 2.55320072 2.57421472 2.59522871 2.61624271 2.63725671
2.65827071 2.6792847 2.7002987 2.7213127 2.7423267 2.7633407
2.78435469 2.80536869 2.82638269 2.84739669 2.86841068 2.88942468
2.91043868 2.93145268 2.95246667 2.97348067 2.99449467 3.01550867
3.03652267 3.05753666 3.07855066 3.09956466 3.12057866 3.14159265]

[ 0  1  2  3  4  5  6  7  8  9 10 11]
[ 0.          0.08333333  0.16666667  0.25        0.33333333  0.41666667
  0.5         0.58333333  0.66666667  0.75        0.83333333  0.91666667]
[ 0.95962168  0.83510776  0.59960879  0.9103227   0.86161055  0.85219339
  0.64341482  0.50396784  0.79940237  0.78113541  0.66371799  0.63459297]
[ 0.65987664  0.87527832  0.79239077  0.61438775  0.44085434  0.38703261
  0.40706581  0.2836271   0.25465063  0.20754596  0.124999    0.08099565]
(0, 0.65987664052659789)
(1, 0.87527832104794756)
(2, 0.79239077290271298)
(3, 0.61438775127130618)
(4, 0.44085434356099779)
(5, 0.3870326100974873)
(6, 0.40706580998264275)
(7, 0.2836271049672956)
(8, 0.2546506260468242)
(9, 0.20754596219057092)
(10, 0.12499900221786377)
(11, 0.080995646704109761)
[-3.14159265 -3.12057866 -3.09956466 -3.07855066 -3.05753666 -3.03652267
 -3.01550867 -2.99449467 -2.97348067 -2.95246667 -2.93145268 -2.91043868
 -2.88942468 -2.86841068 -2.84739669 -2.82638269 -2.80536869 -2.78435469
 -2.7633407  -2.7423267  -2.7213127  -2.7002987  -2.6792847  -2.65827071
 -2.63725671 -2.61624271 -2.59522871 -2.57421472 -2.55320072 -2.53218672
 -2.51117272 -2.49015873 -2.46914473 -2.44813073 -2.42711673 -2.40610273
 -2.38508874 -2.36407474 -2.34306074 -2.32204674 -2.30103275 -2.28001875
 -2.25900475 -2.23799075 -2.21697676 -2.19596276 -2.17494876 -2.15393476
 -2.13292076 -2.11190677 -2.09089277 -2.06987877 -2.04886477 -2.02785078
 -2.00683678 -1.98582278 -1.96480878 -1.94379479 -1.92278079 -1.90176679
 -1.88075279 -1.85973879 -1.8387248  -1.8177108  -1.7966968  -1.7756828
 -1.75466881 -1.73365481 -1.71264081 -1.69162681 -1.67061282 -1.64959882
 -1.62858482 -1.60757082 -1.58655683 -1.56554283 -1.54452883 -1.52351483
 -1.50250083 -1.48148684 -1.46047284 -1.43945884 -1.41844484 -1.39743085
 -1.37641685 -1.35540285 -1.33438885 -1.31337486 -1.29236086 -1.27134686
 -1.25033286 -1.22931886 -1.20830487 -1.18729087 -1.16627687 -1.14526287
 -1.12424888 -1.10323488 -1.08222088 -1.06120688 -1.04019289 -1.01917889
 -0.99816489 -0.97715089 -0.95613689 -0.9351229  -0.9141089  -0.8930949
 -0.8720809  -0.85106691 -0.83005291 -0.80903891 -0.78802491 -0.76701092
 -0.74599692 -0.72498292 -0.70396892 -0.68295492 -0.66194093 -0.64092693
 -0.61991293 -0.59889893 -0.57788494 -0.55687094 -0.53585694 -0.51484294
 -0.49382895 -0.47281495 -0.45180095 -0.43078695 -0.40977295 -0.38875896
 -0.36774496 -0.34673096 -0.32571696 -0.30470297 -0.28368897 -0.26267497
 -0.24166097 -0.22064698 -0.19963298 -0.17861898 -0.15760498 -0.13659098
 -0.11557699 -0.09456299 -0.07354899 -0.05253499 -0.031521   -0.010507
  0.010507    0.031521    0.05253499  0.07354899  0.09456299  0.11557699
  0.13659098  0.15760498  0.17861898  0.19963298  0.22064698  0.24166097
  0.26267497  0.28368897  0.30470297  0.32571696  0.34673096  0.36774496
  0.38875896  0.40977295  0.43078695  0.45180095  0.47281495  0.49382895
  0.51484294  0.53585694  0.55687094  0.57788494  0.59889893  0.61991293
  0.64092693  0.66194093  0.68295492  0.70396892  0.72498292  0.74599692
  0.76701092  0.78802491  0.80903891  0.83005291  0.85106691  0.8720809
  0.8930949   0.9141089   0.9351229   0.95613689  0.97715089  0.99816489
  1.01917889  1.04019289  1.06120688  1.08222088  1.10323488  1.12424888
  1.14526287  1.16627687  1.18729087  1.20830487  1.22931886  1.25033286
  1.27134686  1.29236086  1.31337486  1.33438885  1.35540285  1.37641685
  1.39743085  1.41844484  1.43945884  1.46047284  1.48148684  1.50250083
  1.52351483  1.54452883  1.56554283  1.58655683  1.60757082  1.62858482
  1.64959882  1.67061282  1.69162681  1.71264081  1.73365481  1.75466881
  1.7756828   1.7966968   1.8177108   1.8387248   1.85973879  1.88075279
  1.90176679  1.92278079  1.94379479  1.96480878  1.98582278  2.00683678
  2.02785078  2.04886477  2.06987877  2.09089277  2.11190677  2.13292076
  2.15393476  2.17494876  2.19596276  2.21697676  2.23799075  2.25900475
  2.28001875  2.30103275  2.32204674  2.34306074  2.36407474  2.38508874
  2.40610273  2.42711673  2.44813073  2.46914473  2.49015873  2.51117272
  2.53218672  2.55320072  2.57421472  2.59522871  2.61624271  2.63725671
  2.65827071  2.6792847   2.7002987   2.7213127   2.7423267   2.7633407
  2.78435469  2.80536869  2.82638269  2.84739669  2.86841068  2.88942468
  2.91043868  2.93145268  2.95246667  2.97348067  2.99449467  3.01550867
  3.03652267  3.05753666  3.07855066  3.09956466  3.12057866  3.14159265]

Python Matplotlib模块--pylab的更多相关文章

  1. Python Matplotlib模块--pyplot

    #-*- coding: utf- -*- ''' numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=No ...

  2. Windows python 安装 nNumpy、Scipy、matplotlib模块

    折腾了 很久,总结一些. 首先如果python 是64位,安装32位的numpy ,Scipy,或者matplotlib 模块. 会出现很多问题. 比如当你 在python 导入 Numpy 时,导入 ...

  3. python 爬虫与数据可视化--matplotlib模块应用

    一.数据分析的目的(利用大数据量数据分析,帮助人们做出战略决策) 二.什么是matplotlib? matplotlib: 最流行的Python底层绘图库,主要做数据可视化图表,名字取材于MATLAB ...

  4. 为python安装matplotlib模块

    matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,执行python -m pip install - ...

  5. Python使用matplotlib模块绘制多条折线图、散点图

    用matplotlib模块 #!usr/bin/env python #encoding:utf-8 ''' __Author__:沂水寒城 功能:折线图.散点图测试 ''' import rando ...

  6. windows_64下python下载安装Numpy、Scipy、matplotlib模块

    本文应用的python3.6.3及其对应的Numpy.Scipy.matplotlib计算模块的cp36版本,其中Numpy是需要MKL版本的Numpy,这是后续安装Scipy的需要(本机系统win7 ...

  7. windows下python安装Numpy、Scipy、matplotlib模块(转载)

    python下载链接     Numpy下载链接 python中Numpy包的安装及使用 Numpy包的安装 准备工作 Python安装 pip安装 将pip所在的文件夹添加到环境变量path路径中 ...

  8. python 1: 解决linux系统下python中的matplotlib模块内的pyplot输出图片不能显示中文的问题

    问题: 我在ubuntu14.04下用python中的matplotlib模块内的pyplot输出图片不能显示中文,怎么解决呢? 解决: 1.指定默认编码为UTF-8: 在python代码开头加入如下 ...

  9. Python使用pip安装matplotlib模块

    matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,建议执行python -m pip install ...

随机推荐

  1. Python爬虫入门教程: All IT eBooks多线程爬取

    All IT eBooks多线程爬取-写在前面 对一个爬虫爱好者来说,或多或少都有这么一点点的收集癖 ~ 发现好的图片,发现好的书籍,发现各种能存放在电脑上的东西,都喜欢把它批量的爬取下来. 然后放着 ...

  2. vue项目编译配置 用于结合Django项目

  3. 【】node基础概念问题(转载)

    1.nodejs编写HelloWord,了解什么是nodejs,nodejs有什么特点   2.nodejs的模块怎么用,如何载入别的模块(require),如何给另一模块调用(module, mod ...

  4. 如何爬取可用的IP代理

    上一篇说到对付反爬虫有一个很关键的方法就是使用IP代理,那么我们应该如何获取这些可用的IP代理呢?这里分享一下自己这两天的一些爬取IP代理的心得体会. 1 步骤 1.找到几个提供免费IP代理的网站,获 ...

  5. Codeforces 22E(图论)

    题意: 给出n个节点,以及和这个节点指向的节点fi,表示从i能够到达fi,问至少需要添加多少条边能够使得原图变为强连通分量, 输出边数及添加的边,多解输出任意一组解. 2 <= n <= ...

  6. Python/Java程序员面试必备常用问题解析与答案

    转自AI算法联盟,理解python技术问题,以及一些常见的java面试中经常遇到的问题,这些面试问题分为四类: 是什么(what) 如何做(how) 说区别/谈优势(difference) 实践操作( ...

  7. Ubuntu16.04安装deb文件时提示:此软件来自第三方且可能包含非自由组件

    解决方式: 1.在Ubuntu软件中心安装GDebi. 2.安装好之后,选择这个要安装的deb文件右键,打开方式选择GDebi,然后输入管理员密码等待安装,期间如果不行需要重试几次. 3.另外的方法, ...

  8. 踩坑录-libreoffice fatal error com.sun.start.ucb.Interactive.AugmentedIOException: a folder could not be created

    错误概要: 1.LibreOffice可以正常使用: 2.启动tomcat报错如下: Fatal error The application cannot be started. ][context= ...

  9. 华为OJ:数字颠倒

    将数字转成一个字符串即可了. import java.util.Scanner; public class convertNumber { public static void main(String ...

  10. MyEclipse+Tomcat+MAVEN+SVN项目完整环境搭建

    这次换了台电脑,所以须要又一次配置一次项目开发环境,过程中的种种,记录下来,便于以后再次安装.同一时候给大家一个參考. 1.JDK的安装 首先下载JDK,这个从sun公司官网能够下载.依据自己的系统选 ...