Muyun99's wiki Muyun99's wiki
首页
学术搬砖
学习笔记
生活杂谈
wiki搬运
资源收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Muyun99

努力成为一个善良的人
首页
学术搬砖
学习笔记
生活杂谈
wiki搬运
资源收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 常见 bug 修复

  • 环境配置

  • 常用库的常见用法

    • pandas 库常用用法
    • glob 库常用用法
    • sklearn 库常用用法
    • matplotlib 库常用用法--散点图绘制
      • 图像处理库的常用用法
      • ubuntu 系统常用命令
      • numpy 库常用用法
      • matplotlib 库常用用法
      • tmux 常用用法
      • Docker 常用用法
      • zsh 相关用法
      • 常见的专有名词
      • sharelatex 部署
      • typecho 部署
      • cpp STL 常用用法
      • Tensorboard 常用用法
    • wiki搬运
    • 常用库的常见用法
    Muyun99
    2021-08-11

    matplotlib 库常用用法--散点图绘制

    # 散点图绘制

    # 1、代码示例

    import numpy as np
    import matplotlib.pyplot as plt
    
    # Fixing random state for reproducibility
    np.random.seed(19680801)
    
    
    N = 50
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)
    area = (30 * np.random.rand(N))**2  # 0 to 15 point radii
    
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)
    plt.show()
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

    image-20210705215746993

    # 2、自写代码

     ax.scatter(noisy_sample_pd1, noisy_sample_pd2, c='lightcoral', marker='+', alpha=0.6, label="Noisy Sample")  
     ax.scatter(clean_sample_pd1, clean_sample_pd2, c='darkcyan',  marker='x', alpha=0.6, label="Clean Sample")
    
    # concat two image
    def mix_img(path1, path2, save_path):
        img1 = cv2.imread(path1)
        img2 = cv2.imread(path2)
        image_concat = np.concatenate([img1, img2], axis=1)
        cv2.imwrite(save_path, img=image_concat)
    
    1
    2
    3
    4
    5
    6
    7
    8
    9

    # mixed

    # 3、参数解析

    • c 参数如下图(参考链接 (opens new window))

      ../../_images/named_colors.png

    • m 参数如下图(参考链接 (opens new window))

      image-20210705220413714

    # 拼图

    image_concat1 = np.concatenate([img, mask], axis=1)
    image_concat2 = np.concatenate([img, color_mask], axis=1)
    mmcv.imwrite(image_concat1, 'test1.png')
    mmcv.imwrite(image_concat2, 'test2.png')
    
    plt.subplot(1, 3, 1)
    plt.imshow(img)
    plt.title("img", fontsize=8)
    
    plt.subplot(1, 3, 2)
    plt.imshow(mask, cmap ='gray')
    plt.title(f"img_noise_erode_", fontsize=8)
    
    plt.subplot(1, 3, 3)
    plt.imshow(color_mask)
    plt.title(f"img_noise_dilate_", fontsize=8)
    
    plt.savefig('test.png')
    plt.show()
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

    # 参考资料

    • https://matplotlib.org/stable/api/index.html

    • https://matplotlib.org/2.0.2/examples/color/named_colors.html

    • https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers

    • https://matplotlib.org/stable/gallery/shapes_and_collections/scatter.html#sphx-glr-gallery-shapes-and-collections-scatter-py

    • https://matplotlib.org/stable/tutorials/introductory/sample_plots.html#sphx-glr-tutorials-introductory-sample-plots-py

    参考资料

    • https://flashgene.com/archives/163100.html
    上次更新: 2021/09/26, 00:09:41
    sklearn 库常用用法
    图像处理库的常用用法

    ← sklearn 库常用用法 图像处理库的常用用法→

    最近更新
    01
    Structured Knowledge Distillation for Semantic Segmentation
    06-03
    02
    README 美化
    05-20
    03
    常见 Tricks 代码片段
    05-12
    更多文章>
    Theme by Vdoing | Copyright © 2021-2023 Muyun99 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式
    ×