• plt


    1、figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)

    num:图像编号或名称,数字为编号 ,字符串为名称

    figsize:指定figure的宽和高,单位为英寸;

    dpi参数指定绘图对象的分辨率,即每英寸多少个像素,缺省值为80      

    facecolor:背景颜色

    edgecolor:边框颜色

    frameon:是否显示边框

    plt.figure(num=3)

    plt.plot(x,y,color='red',linewidth=1.0,linestyle='--')     scatter、bar

    plt.show()

    plt.text(x, y, 内容)

    坐标轴:

      plt.xlabel('x')

      plt.xlim(a, b)         坐标范围

      plt.xticks([],[])     改变原来的坐标表示,可将坐标转化为字符串

      plt.xticks(())          去除坐标轴

      plt.gca()  get current axis

      ax.spines['right'].set_color('none')

      ax.xaxis.set_ticks_position('bottom')

    图例:

      plt.plot(x, y, label='abc')

      plt.legend(loc=,handles,labels=)

        loc:best、upper right

    1、figure和subplot

    plt.figure(1)  # figure1
    plt.subplot(211) # figure1中的第一个子图
    plt.plot([1, 2, 3])
    plt.subplot(212) # figure1中的第二个子图
    plt.plot([4, 5, 6])

    plt.figure(2) # figure2
    # 默认使用subplot(111),此时figure2为当前figure
    plt.plot([4, 5, 6])

    plt.figure(1) # 设置figure1为当前figure;
    # 但是subplot(212)为当前子图,使subplot(211)为当前子图
    plt.subplot(211)
    plt.title('Easy as 1, 2, 3') # 对subplot(211)命名
    plt.show()
    plt.savefig('test.png')

    2、subplots

    fig, figs = plt.subplots(1, len(images), figsize=(12, 12))
    for f, image, label in zip(figs, images, labels):
    f.imshow(image.squeeze().numpy() * 0.5 + 0.5)
    f.set_title(label)
    f.axes.get_xaxis().set_visible(False)
    f.axes.get_yaxis().set_visible(False)
    plt.show()

    3、Rectangle

    plt.Rectangle(xy=, width=, height=, fill=False, edgecolor=, linewidth=)


  • 相关阅读:
    appium连接夜游神的方法
    selenium自动化测试配置工具整理
    appium+Python 启动app(三)登录
    appium+Python 启动app(二)
    appium+Python 启动app(一)
    appium滑动操作(向上、向下、向左、向右)
    【Prometheus专题】4. Prometheus通过webhook集成Slack或Mattermost发送告警
    【Prometheus专题】3. Prometheus监控组件的配置
    【Prometheus专题】2. Prometheus监控组件安装
    【Prometheus专题】1. Prometheus介绍(何为Prometheus)
  • 原文地址:https://www.cnblogs.com/liujianing/p/12213345.html
Copyright © 2020-2023  润新知