zoukankan      html  css  js  c++  java
  • 20.python-matplotlib

    #matplotlib
    
    import matplotlib
    
    import numpy as np
    import matplotlib.pyplot as plt
    
    
    def simple_line(x,y,figure_no):
        plt.figure(figure_no)
        plt.plot(x,y)
        plt.xlabel('x values')
        plt.ylabel('y values')
        plt.title('Simple Line')
    
    
    def simple_dots(x,y,figure_no):
        plt.figure(figure_no)
        plt.plot(x,y,'or')
        plt.xlabel('x values')
        plt.ylabel('y values')
        plt.title('Simple Dots')
    
    def simple_scatter(x,y,figure_no):
        plt.figure(figure_no)
        plt.scatter(x,y)
        plt.xlabel('x values')
        plt.ylabel('y values')
        plt.title('Simple Scatter')
    
    def scatter_with_color(x,y,labels,figure_no):
        plt.figure(figure_no)
        plt.scatter(x,y,c=labels)
        plt.xlabel('x values')
        plt.ylabel('y values')
        plt.title('Scatter with color')
    
    figure_no=1
    x=np.arange(20)
    y=np.array([np.power(xx,2) for xx in x])
    simple_line(x,y,figure_no)
    
    figure_no+=1
    simple_dots(x,y,figure_no)
    
    x=np.random.uniform(size=100)
    y=np.random.uniform(size=100)
    figure_no+=1
    simple_scatter(x,y,figure_no)
    
    labels=np.random.randint(2,size=100)
    figure_no+=1
    scatter_with_color(x,y,labels,figure_no)
    plt.show()
  • 相关阅读:
    Excel Formulas-Vlookup
    C#字符串与unicode互相转换
    string.IsNullOrWhiteSpace
    CREATE SEQUENCE sqlserver
    error CS1056
    WebExceptionStatus
    运维踩坑记
    C# 快捷命令
    sqlserver2019安装教程
    sql server 数据库mdf文件和log文件过大问题
  • 原文地址:https://www.cnblogs.com/wjc920/p/9256144.html
Copyright © 2011-2022 走看看