美文网首页
Matplotlib库的入门

Matplotlib库的入门

作者: 不做大哥好多年 | 来源:发表于2017-06-05 13:45 被阅读71次

    import matplotlib.pyplot as plt(引用模块的别名)


    pyplot的plot()函数

    plt.plot(x,y,format_string,**kwargs)

    x         :x轴数据,列表或数组,可选

    y         :y轴数据,列表或数组

    format_string    :控制曲线的格式字符串,可选

    **kwargs           :第二组或更多(x,y,format_string)

    当绘制多条曲线时,各条曲线的x不能省略




    plt.plot(x,y,format_string,**kwargs)

    **kwargs    :第二组或更多(x,y,format_string)

    color           :控制颜色,color =‘green’

    linestyle      :线条风格,linestyle =‘dashed’

    marker         :标记风格,marker = ‘o’

    markerfacecolor :标记颜色,markerfacecolor = 'blue'

    markersize      :标记尺寸,markersize=20

    rcParams的属性

    font.family   用于显示字体的名字

    font.strle      字体风格,正常‘normal’  或斜体‘italic’

    font.size     字体大小,整数字号或者'large'、'x-small'


    pyplot的文本显示函数

    plt.xlabel()       对x轴增加文本标签

    plt.ylabel()        对y轴增加文本标签

    plt.title()           对图形整体增加文本标签

    plt.text()            在任意位置增加文本

    plt.annotate()     在图形中增加带箭头的注解

    pyplot的子绘图区域

    pyplot基础图标函数概述

    plt.plot(x,y,fmt,...)                                 绘制一个坐标图

    plt.boxplot(data,notch,position)          绘制一个箱形图

    plt.bar(left,height,width,bottom)         绘制一个条形图

    plt.barh(width,bottom,left,height)       绘制一个横向条形图

    plt.polar(theta,r)                                   绘制极坐标图

    plt.pie(data,explode)                            绘制饼图

     plt.psd(x,NFFT=256,pad_to,Fs)       绘制功率谱密度图

    plt.specgram(x,NFFT=256,pad_to,F)  绘制谱图

    plt.cohere(x,y,NFFT=256,Fs)             绘制X-Y的相关性函数

    plt.scatter(x,y)                                       绘制散点图,其中,x和y长度相同

    plt.step(x,y,where)                                绘制步阶图

    plt.hist(x,bins,normed)                          绘制直方图

    plt.contour(X,Y,Z,N)                              绘制等值图

    plt.vlines()                                              绘制垂直图

    plt.stem(x,y,linefmt,markerfmt)             绘制柴火图

    plt.plot_date()                                        绘制数据日期



    相关文章

      网友评论

          本文标题:Matplotlib库的入门

          本文链接:https://www.haomeiwen.com/subject/jelifxtx.html