使用matlibp自定义y标签

2024-05-20 08:21:10 发布

您现在位置:Python中文网/ 问答频道 /正文

希望这是一个简单的问题。我正在尝试创建一个控制图,我想知道是否有一种方法可以在图表y标签上的特定位置添加上限和下限控制标签,例如UCLLCL(请参见屏幕截图)。你知道吗

以下是我的代码:

def control_chart(x,y,fig_num=1, sigma=1, title="", X_MIN=None,
            X_MAX=None, Y_MIN=None, Y_MAX=None,
            xlabel="", ylabel=""):
    ...

    fig1 = plt.figure(fig_num)

    ...

    plt.axis([X_MIN, X_MAX,Y_MIN,Y_MAX])
    plt.plot(week, y, "black")
    plt.plot(week, [x_bar for _ in range(len(x))], "red")
    plt.plot(week, [UCL for _ in range(len(x))],'r-.', lw=2)
    plt.plot(week, [LCL for _ in range(len(x))],'r-.',lw=2)
    plt.plot(o1,o2,'ro')    
    plt.title(title)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

enter image description here


Tags: innoneforlenplottitlerangeplt