小编Law*_*nce的帖子

Numpy.where函数找不到数组中的值...任何人都知道为什么?

我一直在尝试使用python的numpy.where函数来确定特定值的位置,但由于某种原因,它错误地确定False了实际找到值的位置.从而返回一个空数组.见下文:

>>>lbpoly=numpy.array([ 5.45  5.5   5.55  5.6   5.65  5.7   5.75  5.8   5.85  5.9   5.95  6.
6.05  6.1   6.15  6.2   6.25  6.3   6.35  6.4   6.45  6.5   6.55  6.6
6.65  6.7   6.75  6.8   6.85  6.9   6.95  7.  ])

>>>cpah=numpy.where(lbpoly==6.2)

>>>print cpah

>>>(array([], dtype=int32),)
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么会这样?我尝试了许多不同的变体,甚至使用<>逻辑.但这会产生2个值的指数.

python arrays numpy where

8
推荐指数
1
解决办法
437
查看次数

Matplotlib vline标签参数未显示

我想用matplotlib的.vline命令标记我的垂直线,但由于某种原因,label参数没有做任何事情/在最终的情节中显示任何内容.有谁知道如何让标签显示?

plt.vlines(x=pah, ymin=0, ymax=0.6, colors='0.75', linestyles='dashed', label='PAHs')
Run Code Online (Sandbox Code Playgroud)

一切都与标签不同.

非常感谢,

大号

python matplotlib enthought

7
推荐指数
1
解决办法
9647
查看次数

标签 统计

python ×2

arrays ×1

enthought ×1

matplotlib ×1

numpy ×1

where ×1