Advertisement

matplotlib用于多个子图在同一页面显示

阅读量:
复制代码
    import matplotlib.pyplot as plt
    import numpy as np
    import math
    plt.rcParams['font.sans-serif']=['SimHei'] # 用来正常显示中文标签
    plt.rcParams['axes.unicode_minus']=False # 用来正常显示负号
    
    x = np.linspace(-math.pi, math.pi)
    y1 = np.sin(x)
    y2 = np.cos(x)
    y3 = np.tan(x)
    
    fig=plt.figure(figsize=(12,8))
    plt.figure(1)
    ax1 = plt.subplot(221)
    ax1.plot(x,y1, color="r",linestyle = "--")
    plt.title('y1=sin(x),x∈[-π,π]',fontsize=17)
    plt.xlim((-math.pi, math.pi))
    plt.xticks(fontsize=15)
    plt.ylim((-1.01, 1.01))
    my_y_ticks = np.arange(-1,1.01

全部评论 (0)

还没有任何评论哟~