Python 使用matlibplot自定义y标签
希望这是一个简单的问题。我正在尝试创建一个控制图,我想知道是否有办法在图表y标签上的特定位置添加上限和下限标签,如UCL,LCL(参见屏幕截图) 以下是我的代码的一个例外:Python 使用matlibplot自定义y标签,python,python-2.7,python-3.x,matplotlib,Python,Python 2.7,Python 3.x,Matplotlib,希望这是一个简单的问题。我正在尝试创建一个控制图,我想知道是否有办法在图表y标签上的特定位置添加上限和下限标签,如UCL,LCL(参见屏幕截图) 以下是我的代码的一个例外: 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=""): ... fig
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)
这行吗
plt.text(X_MAX, UCL, "UCL")`
我无法测试它,因为您的代码中没有提供数据,所以我无法运行它。您是说要在右侧添加标签,还是在左侧添加现有的y轴标签?如果可能,请在右侧添加