Matplotlib Notes

  1. import matplotlib.numerix as n a = n.arange(10)   #a = array[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] b = n.take(a, range(2, 5))   #b = array[2, 3, 4]

    xlable(‘time (s)')                #x轴的标题

    ylable(’ volts ‘)                  #y轴的标题

    title(‘A really simple plot’)               #图表的标题

    grid(True)                          #是否有网格

    删除前面画的图像重新画:

    hold(False)

    plot(t,s)

    或者

    clf()    #clear the figure

    cla()   #clear the axes

figure()

axes([0.1,0.1,0.71,0.8]) plot([0,1],[0,1],label="line 1”) hold(1) plot([0,1],[1,0.5],label="line 2”) legend(loc=(1.03,0.2)) show()

axes(rect, axisbg=’w’) where rect=[left, bottom, width, height] in normalized (0,1) units. axisbg

is the background color for the axis, default white. 比如: from pylab import * axes([0.2, 0.5, 0.2, 0.2], axisbg = ‘y’) plot([1,2,3,4], [1,4,9,16], ‘ro’) axis([0, 10, 0, 20]) show()

cursor = Cursor(ax, useblit=True, color='red', linewidth=2 )

动画:

from pylab import * import time ion() x = arange(0,2*pi,0.01)            # x-array line, = plot(x,sin(x)) for i in arange(1,200):     line.set_ydata(sin(x+i/10.0))  # update the data     draw()                         # redraw the canvas show()

sd

[温馨提示]:该文章由原博客园导入而来,如排版效果不佳,请移步:http://www.cnblogs.com/coderzh/archive/2008/09/10/1288044.html

微信扫一扫交流

作者:CoderZh
微信关注:hacker-thinking (代码随想)
本文出处:https://blog.coderzh.com/2008/09/10/1288044/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。