matplotlib绘制常见统计图

  1. 绘制折线图:plot([x], y, [fmt], data=None, **kwargs)
    绘制多条线 :plot([x], y, [fmt], [x2], y2, [fmt2], …, **kwargs)
    The coordinates of the points or line nodes are given by x, y.
    fmt is a convenient way for defining basic formatting like color, marker and linestyle.
    data:An object with labelled data. If given, provide the label names to
    plot in x and y
    **kwargs : .Line2D properties, optional
    kwargs are used to specify properties like a line label (for
    auto legends), linewidth, antialiasing, marker face color.
    2)绘制散点图:
    scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, data=None, **kwargs)

    s: 点的规格
    c:颜色
    cmap:颜色映射
    edgecolors:删除数据点的轮廓

    3)绘制柱状图:
    bar(x, height, width=0.8, bottom=None, *, align=‘center’, data=None, **kwargs)
    align : {‘center’, ‘edge’}

  2. 修饰
    pit.title() 加标题
    pit.xlabel() x轴加标签
    pit.ylabel()
    plt.tick_params(axis,labelsize ) 设置刻度标记的大小
    axis = xlabel / ylabel / both
    plt.axis([x_min, x_max, y_min, y_max]) 设置坐标轴的取值范围
    plt.savefig() plt.savefig(‘work_1’, dpi=800, bbox_inches=‘tight’,format = ‘pdf’)
    保存图片,名称 像素 裁剪掉多余的空白 保存的格式

    5) 中文显示plt.rc(‘font’, family=‘STSong’, size=14) 字体,及字号大小
    plt.rc(‘axes’, unicode_minus=False)

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值