从散点图中删除渐近线,并在其上绘制线

问题描述 投票:0回答:1

绘制2个星系等效宽度比率列表,我将它们相互绘制。然后,我想消除线y =(0.61)/(x-0.05)+1.3上方的所有点,以便仅线下方的点保留在图中。但是,由于这条绘制的线会创建渐近线,因此我不希望某些点保持可见状态,因为它们在技术上低于该线。这是我到目前为止的内容:

x = np.linspace(-5, 5, 100)
filteredx = list()
filteredy = list()
for ii in range(20000):
    if OT[ii] < (0.61) / (NT[ii] - 0.05) + 1.3:
        filteredx.append(NT[ii])
        filteredy.append(OT[ii])
plt.scatter(filteredx, filteredy, marker='.', color='r', label="StarBursts")
plt.plot(x,y, linewidth=1, linestyle='-')
plt.plot(x, y, '-k')
plt.plot(x, y2, '--k')
plt.xlabel('log(NII/HA)', color='#1C2833')
plt.ylabel('log(OIII/HB)', color='#1C2833')
plt.ylim(-1,1.5)   
plt.xlim(-2,0.5)
plt.legend()
plt.show()

有人知道一种方法可以消除渐近线并因此导致这些点消失吗?提前致谢! edit:Here is the plot for more clarity

python python-3.x matplotlib scatter-plot
1个回答
0
投票

如果您更改

plt.plot(x, y, linewidth=1, linestyle='-')
plt.plot(x, y, '-k')

plt.plot(x[x > 0.05], y[x > 0.05], '-k')
plt.plot(x[x < 0.05], y[x < 0.05], '-k')

使用随机生成的数据:

enter image description here

渐近线将不会绘制。有关更多详细信息,请参见我对previous question的回答以获取完整示例。

© www.soinside.com 2019 - 2024. All rights reserved.