使用x matplotlib

时间:2017-07-23 09:47:06

标签: python matplotlib anaconda

我有一个像这样的matplotlib图:

我尝试使用红色' x'来标记超出绿色范围(由lower_boundupper_bound定义)的图。

下面是我的代码,我最初编写的循环是为了创建x' s注释掉的:

y = df_new[row_index].tolist()
x = range(0, len(y))
x_axis = buckets
y_axis = df_shader.loc[df_shader.index.isin([row_index]) & df_shader['Bucket'].between(1, 144), data_field].tolist()
minus = df_shader.loc[df_shader.index.isin([row_index]) & df_shader['Bucket'].between(1, 144), 'Lower'].tolist()
plus = df_shader.loc[df_shader.index.isin([row_index]) & df_shader['Bucket'].between(1, 144), 'Upper'].tolist()
del y_axis[-1], minus[-2], plus[-2]


plt.title(title)
plt.xlabel("Time of Day (10m Intervals)")
plt.ylabel(data_field + " values for " + row_index)

standevs = df_shader.loc[df_shader.index.isin([row_index]) & df_shader['Bucket'].between(1, 144), 'StanDev'].tolist()
del standevs[-1]
lower_bound = np.array(y_axis) - np.array(standevs)
upper_bound = np.array(y_axis) + np.array(standevs)
minus = np.array(minus)
min2 = minus - np.array(standevs)
plus = np.array(plus)
pl2 = plus + np.array(standevs)

meh = max(upper_bound.tolist())
moh = min(lower_bound.tolist())

plt.axhline(y=meh, color='red')
plt.axhline(y=moh, color='red') #Intercepts
plt.fill_between(x_axis, upper_bound, pl2, color='orange')
plt.fill_between(x_axis, lower_bound, upper_bound, color='lightgreen')
plt.fill_between(x_axis, min2, lower_bound, color='orange')

#   for right, up in x, y:
#       if up > upper_bound:
#           plt.plot(right,up,'rx')
#       if up < lower_bound:
#           plt.plot(right, up, 'rx')
#       else:
#           plt.plot(right, up)

plt.plot(x,y)
plt.show()

如何打印出x?

0 个答案:

没有答案