pylab的目的

Pylab combines the functionality of pyplot with the capabilities of NumPy in a single namespace, and therefore you do not need to import NumPy separately. Furthermore, if you import pylab, pyplot, and NumPy functions can be called directly without any reference to a module (namespace), making the environment more similar to Matlab.

简而言之,from pylab import *这一句话就引入了numpy、matplotlib等常用库,避免了多个import语句。一句话就创造了一个非常类似matlab的编程环境。

pylab的模块包括了许多NumPy和pyplot模块中常用的函数,方便用户快速进行计算和绘图,十分适合在IPython交互式环境中使用。

pylab模块非常单薄,查看pylab源代码可以发现此文件只有80余行,主要内容就是导入一堆包。matplot的主要内容还是在pyplot包中。

阅读以下程序,搜索一下引入的各个包的作用。

from __future__ import (absolute_import, division, print_function,unicode_literals)from matplotlib.externals import siximport sys, warningsfrom matplotlib.cbook import flatten, is_string_like, exception_to_str, \silent_list, iterable, dedentimport matplotlib as mpl
# make mpl.finance module available for backwards compatability, in case folks
# using pylab interface depended on not having to import it
import matplotlib.financefrom matplotlib.dates import date2num, num2date,\datestr2num, strpdate2num, drange,\epoch2num, num2epoch, mx2num,\DateFormatter, IndexDateFormatter, DateLocator,\RRuleLocator, YearLocator, MonthLocator, WeekdayLocator,\DayLocator, HourLocator, MinuteLocator, SecondLocator,\rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, MONTHLY,\WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY, relativedeltaimport matplotlib.dates  # Do we need this at all?# bring all the  symbols in so folks can import them from
# pylab in one fell swoop## We are still importing too many things from mlab; more cleanup is needed.from matplotlib.mlab import griddata, stineman_interp, slopes, \inside_poly, poly_below, poly_between, \is_closed_polygon, path_length, distances_along_curve, vector_lengthsfrom matplotlib.mlab import window_hanning, window_none,  detrend, demean, \detrend_mean, detrend_none, detrend_linear, entropy, normpdf, \find, longest_contiguous_ones, longest_ones, \prctile, prctile_rank, \center_matrix, rk4, bivariate_normal, get_xyz_where, \get_sparse_matrix, dist, \dist_point_to_segment, segments_intersect, fftsurr, movavg, \exp_safe, \amap, rms_flat, l1norm, l2norm, norm_flat, frange,  identity, \base_repr, binary_repr, log2, ispower2, \rec_append_fields, rec_drop_fields, rec_join, csv2rec, rec2csv, isvectorimport matplotlib.mlab as mlab
import matplotlib.cbook as cbookfrom numpy import *
from numpy.fft import *
from numpy.random import *
from numpy.linalg import *from matplotlib.pyplot import *# provide the recommended module abbrevs in the pylab namespace
import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma# don't let numpy's datetime hide stdlib
import datetime# This is needed, or bytes will be numpy.random.bytes from
# "from numpy.random import *" above
bytes = __builtins__['bytes']

注释之中列出了可用的命令:

This is a procedural interface to the matplotlib object-oriented
plotting library.

The following plotting commands are provided; the majority have
MATLAB |reg| [*]_ analogs and similar arguments.

.. |reg| unicode:: 0xAE

_Plotting commands
acorr - plot the autocorrelation function
annotate - annotate something in the figure
arrow - add an arrow to the axes
axes - Create a new axes
axhline - draw a horizontal line across axes
axvline - draw a vertical line across axes
axhspan - draw a horizontal bar across axes
axvspan - draw a vertical bar across axes
axis - Set or return the current axis limits
autoscale - turn axis autoscaling on or off, and apply it
bar - make a bar chart
barh - a horizontal bar chart
broken_barh - a set of horizontal bars with gaps
box - set the axes frame on/off state
boxplot - make a box and whisker plot
violinplot - make a violin plot
cla - clear current axes
clabel - label a contour plot
clf - clear a figure window
clim - adjust the color limits of the current image
close - close a figure window
colorbar - add a colorbar to the current figure
cohere - make a plot of coherence
contour - make a contour plot
contourf - make a filled contour plot
csd - make a plot of cross spectral density
delaxes - delete an axes from the current figure
draw - Force a redraw of the current figure
errorbar - make an errorbar graph
figlegend - make legend on the figure rather than the axes
figimage - make a figure image
figtext - add text in figure coords
figure - create or change active figure
fill - make filled polygons
findobj - recursively find all objects matching some criteria
gca - return the current axes
gcf - return the current figure
gci - get the current image, or None
getp - get a graphics property
grid - set whether gridding is on
hist - make a histogram
hold - set the axes hold state
ioff - turn interaction mode off
ion - turn interaction mode on
isinteractive - return True if interaction mode is on
imread - load image file into array
imsave - save array as an image file
imshow - plot image data
ishold - return the hold state of the current axes
legend - make an axes legend
locator_params - adjust parameters used in locating axis ticks
loglog - a log log plot
matshow - display a matrix in a new figure preserving aspect
margins - set margins used in autoscaling
pause - pause for a specified interval
pcolor - make a pseudocolor plot
pcolormesh - make a pseudocolor plot using a quadrilateral mesh
pie - make a pie chart
plot - make a line plot
plot_date - plot dates
plotfile - plot column data from an ASCII tab/space/comma delimited file
pie - pie charts
polar - make a polar plot on a PolarAxes
psd - make a plot of power spectral density
quiver - make a direction field (arrows) plot
rc - control the default params
rgrids - customize the radial grids and labels for polar
savefig - save the current figure
scatter - make a scatter plot
setp - set a graphics property
semilogx - log x axis
semilogy - log y axis
show - show the figures
specgram - a spectrogram plot
spy - plot sparsity pattern using markers or image
stem - make a stem plot
subplot - make one subplot (numrows, numcols, axesnum)
subplots - make a figure with a set of (numrows, numcols) subplots
subplots_adjust - change the params controlling the subplot positions of current figure
subplot_tool - launch the subplot configuration tool
suptitle - add a figure title
table - add a table to the plot
text - add some text at location x,y to the current axes
thetagrids - customize the radial theta grids and labels for polar
tick_params - control the appearance of ticks and tick labels
ticklabel_format - control the format of tick labels
title - add a title to the current axes
tricontour - make a contour plot on a triangular grid
tricontourf - make a filled contour plot on a triangular grid
tripcolor - make a pseudocolor plot on a triangular grid
triplot - plot a triangular grid
xcorr - plot the autocorrelation function of x and y
xlim - set/get the xlimits
ylim - set/get the ylimits
xticks - set/get the xticks
yticks - set/get the yticks
xlabel - add an xlabel to the current axes
ylabel - add a ylabel to the current axes

autumn - set the default colormap to autumn
bone - set the default colormap to bone
cool - set the default colormap to cool
copper - set the default colormap to copper
flag - set the default colormap to flag
gray - set the default colormap to gray
hot - set the default colormap to hot
hsv - set the default colormap to hsv
jet - set the default colormap to jet
pink - set the default colormap to pink
prism - set the default colormap to prism
spring - set the default colormap to spring
summer - set the default colormap to summer
winter - set the default colormap to winter
spectral - set the default colormap to spectral

_Event handling

connect - register an event handler
disconnect - remove a connected event handler

_Matrix commands

cumprod - the cumulative product along a dimension
cumsum - the cumulative sum along a dimension
detrend - remove the mean or besdt fit line from an array
diag - the k-th diagonal of matrix
diff - the n-th differnce of an array
eig - the eigenvalues and eigen vectors of v
eye - a matrix where the k-th diagonal is ones, else zero
find - return the indices where a condition is nonzero
fliplr - flip the rows of a matrix up/down
flipud - flip the columns of a matrix left/right
linspace - a linear spaced vector of N values from min to max inclusive
logspace - a log spaced vector of N values from min to max inclusive
meshgrid - repeat x and y to make regular matrices
ones - an array of ones
rand - an array from the uniform distribution [0,1]
randn - an array from the normal distribution
rot90 - rotate matrix k*90 degress counterclockwise
squeeze - squeeze an array removing any dimensions of length 1
tri - a triangular matrix
tril - a lower triangular matrix
triu - an upper triangular matrix
vander - the Vandermonde matrix of vector x
svd - singular value decomposition
zeros - a matrix of zeros

_Probability

normpdf - The Gaussian probability density function
rand - random numbers from the uniform distribution
randn - random numbers from the normal distribution

_Statistics

amax - the maximum along dimension m
amin - the minimum along dimension m
corrcoef - correlation coefficient
cov - covariance matrix
mean - the mean along dimension m
median - the median along dimension m
norm - the norm of vector x
prod - the product along dimension m
ptp - the max-min along dimension m
std - the standard deviation along dimension m
asum - the sum along dimension m
ksdensity - the kernel density estimate

_Time series analysis

bartlett - M-point Bartlett window
blackman - M-point Blackman window
cohere - the coherence using average periodiogram
csd - the cross spectral density using average periodiogram
fft - the fast Fourier transform of vector x
hamming - M-point Hamming window
hanning - M-point Hanning window
hist - compute the histogram of x
kaiser - M length Kaiser window
psd - the power spectral density using average periodiogram
sinc - the sinc function of array x

_Dates

date2num - convert python datetimes to numeric representation
drange - create an array of numbers for date plots
num2date - convert numeric type (float days since 0001) to datetime

_Other

angle - the angle of a complex array
griddata - interpolate irregularly distributed data to a regular grid
load - Deprecated--please use loadtxt.
loadtxt - load ASCII data into array.
polyfit - fit x, y to an n-th order polynomial
polyval - evaluate an n-th order polynomial
roots - the roots of the polynomial coefficients in p
save - Deprecated--please use savetxt.
savetxt - save an array to an ASCII file.
trapz - trapezoidal integration

__end

.. [*] MATLAB is a registered trademark of The MathWorks, Inc.

转载于:https://www.cnblogs.com/weiyinfu/p/7878285.html

matplot模块中的pylab相关推荐

  1. python matplot模块

    先将matplot模块导入,并缩写: import matplotlib as mpl 有时候只需要其中的一部分: import matplotlib.pyplot as plt 二维图: 折线图pl ...

  2. Iar环境c语言调用汇编函数,如何在IAR EWARM中通过内联汇编程序在另一个模块中调用C函数?...

    我在硬故障处理程序中有一些程序集.程序集基本上是为了传递当前堆栈指针作为参数(在R0中).它看起来像这样...如何在IAR EWARM中通过内联汇编程序在另一个模块中调用C函数? __asm(&quo ...

  3. 现在无法开始异步操作。异步操作只能在异步处理程序或模块中开始,或在页生存期中的特定事件过程中开始...

    异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 这篇没啥技术含量,用来小记一番 错误信息 "System.Invalid ...

  4. 爬虫之lxml模块中etree.tostring函数的使用

    爬虫之lxml模块中etree.tostring函数的使用 运行下边的代码,观察对比html的原字符串和打印输出的结果 from lxml import etree html_str = ''' &l ...

  5. 爬虫之requests模块中cookies参数的使用

    爬虫之requests模块中cookies参数的使用 上一篇文章在headers参数中携带cookie,也可以使用专门的cookies参数 cookies参数的形式:字典 cookies = {&qu ...

  6. 关于学习Python的一点学习总结(57->正则表达式及re模块中的一些函数)

    关于这个正则表达式,我本人也是有点不完全懂,还在继续学习中. 97.re 1.正则表达式: 1.通配符:正则表达式可与多个字符串匹配,可使用特殊字符来创建这种正则表达式 例如:正则表达式'.ython ...

  7. Magento中如何在模块中使用多张数据表并配置多个model?

    功能介绍: 引用magento开发人员的一句话: Magento has basic one resource to one table resource. 也即是一个资源对应一张数据表. 当有时候, ...

  8. SPC在SAP QM模块中的应用

    SPC在SAP QM模块中的应用 1.点击控制标识符--勾选采样过程.统计过程控制特征. 2.点击定量数据,维护上下限. 以上两点也可以在检验计划中维护. 创建采样过程 QDV1 1.取样类型:只能使 ...

  9. SAP的SD模块中客户的销售视图--扩充客户销售范围

    在SAP中 客户 主数据 有三个视图:一般数据(常规数据),公司代码数据,销售数据. 其中前两个视图由财务会计维护 财务会计会使用FD01这个事务码,维护常规数据 下图就是FD01 而在SD模块中,需 ...

最新文章

  1. Python核心编程学习笔记(一)
  2. 菜鸟学exchange之一:exchange邮件系统的简单安装和部署
  3. 多元二次方程 python_Python 二次方程
  4. zookeeper专题:zookeeper集群搭建和客户端连接
  5. OpenShift 4 之Service Mesh教程(1)- 创建ServiceMesh环境,部署Istio的微服务
  6. Anaconda——Youki常用的conda命令笔记
  7. 华为NP课程笔记10-BGP案例讲解
  8. 海康威视客户端iVMS-4200连接NVR
  9. python入门(三) 实现QQ自动发送消息
  10. dmz区域和虚拟服务器的区别,dmz主机 虚拟服务器
  11. JZOJ5460. 【NOIP2017提高A组冲刺11.7】士兵训练
  12. [bzoj4556][TJOIHEOI2016]字符串
  13. 几种颜色空间(RGB,YUV,YIQ,HSI)的基本概念及转换
  14. 手撕神经网络(1)——神经网络的基本组件
  15. 【孵化器系列采访】创新工场:高端人才成功创业的聚集地
  16. 推荐几个我收藏且星标的嵌入式技术公众号
  17. FlinkX数据同步
  18. 面向对象---抽象和封装
  19. 信息化也需要雅俗包装
  20. 如何将图片上的文字识别成可修改的文本

热门文章

  1. 1号店与京东双剑合璧 否认10月“关门”
  2. 行人重识别技术(Re-ID)概述、研究现状以及相关数据集下载
  3. DB2 SQL语句的优化
  4. 用3D max导入模型时,清除丢失的材质贴图和路径
  5. IDEA Unable to ping server at 1099问题
  6. mysql报错1099_MySQL错误ERROR 1099(HY000):表已被READ锁锁定,无法更新
  7. 国税上云:用云计算提升政府治理
  8. 网页播放音频的3种方法
  9. 缓存的作用和重要指标
  10. javascript 鼠标移入移出改变图片透明度