2014-10-04 94 views
1

我使用python 3.4.1,matplotlib 1.4,ipython 2.3笔记本,Arch Linux。fill_between没有统一填充

我试图通过一条线将平面划分为两部分,例如两个分类区域,其中一个区域具有一个值,另一个区域具有其他值。我对区间[-1,1] x [-1,1]中的区域感兴趣。

这里是一切正常的例子:

import numpy as np 
import matplotlib.pyplot as plt 
a, b = (2.5711100440212684, -0.87718711444141584) 
x = np.arange(-1, 1, 0.001) 
y1 = a*x + b 
y2 = -1 
y3 = 1 
plt.fill_between(x, y1, y2, where=y1>y2, facecolor='green', interpolate=True) 
plt.fill_between(x, y1, y3, where=y1<y3, facecolor='yellow', interpolate=True) 
plt.axis([-1, 1, -1, 1]) 

此代码给了我一张照片,因为我认为它应该: enter image description here

在另一方面,如果我改变的斜坡位,这里就是我得到:

import numpy as np 
import matplotlib.pyplot as plt 
a, b = (4.5711100440212684, -0.87718711444141584) 
x = np.arange(-1, 1, 0.001) 
y1 = a*x + b 
y2 = -1 
y3 = 1 
plt.fill_between(x, y1, y2, where=y1>y2, facecolor='green', interpolate=True) 
plt.fill_between(x, y1, y3, where=y1<y3, facecolor='yellow', interpolate=True) 
plt.axis([-1, 1, -1, 1]) 

enter image description here

有可能我错过了一些东西。如果有人看到这个错误,请告诉我。

编辑:哦,是的,绿色填充似乎适用于所有的斜率值。

回答

1

它适合我。使用Matplotlib每晚构建,Ubuntu 14.04,Python 3.4,,但从控制台运行它。你也尝试过吗?

enter image description here

+0

我现在做了,我仍然得到这个。这似乎是某种错误。你可以检查你的matplotlib版本吗?这可能是matplotlib 1.4.0的错误。 – enedene 2014-10-04 16:27:46

+0

1.5.x和构建是:https://launchpad.net/~takluyver/+archive/ubuntu/matplotlib-daily – tobias47n9e 2014-10-04 16:30:44

+0

好的,谢谢,它一定是一个bug。我会upvote并接受你的答案。 – enedene 2014-10-04 16:32:54