python - 自定义 y 标签)使用 matlibplot

标签 python python-2.7 python-3.x matplotlib

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

下面是我的代码的异常(exception):

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

最佳答案

这个有用吗?

plt.text(X_MAX, UCL, "UCL")` 

我无法测试它,因为您没有在代码中提供数据,所以我无法运行它。

关于python - 自定义 y 标签)使用 matlibplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33863963/

相关文章:

python - 在 ubuntu 中使用 Python 中的 matplotlib 从 csv 文件绘制 2D 图形

Python:合并两个字典

python - 如何在Python中动态创建方法(名称+代码)

python - 按特定逻辑对嵌套列表进行排序 - Python

Python scipy find_simplex 卡住

python - elasticsearch映射字段[name]上的属性[fields]的预期映射,但是得到了一个类java.lang.String

python - 在 Python 中访问全局变量时的导入行为

python - 为什么 sum() 和 min() 的 Python 内置函数要好得多?

python - spark中哪个函数用于通过key组合两个RDD

python - 在 sleep 调用之间捕获信号