【发布时间】:2013-10-11 20:16:08
【问题描述】:
我正在尝试在 matplotlib 中绘制像素值获得非“-1”值的光线追踪路径。换句话说,我有以下代表 4 条光线路径的二维数组。射线穿过的每个像素都有随机值。除了这些相交的像素外,其余的都是“-1”。我想以白色或不可见(不存在)显示值“-1”。怎么可能?
import numpy as np
import scipy as sp
import pylab as pl
M = np.array([[ 0. , -1., -1., -1., -1., -1.],
[ 0.25, -1.,-1.,-1.,-1.,-1.],
[ 0.25, -1., -1., -1.,-1.,-1.],
[ 0.22, -1., -1., -1., -1.,-1.],
[ 0.16, -1., -1., -1., -1.,-1.],
[ 0.16, -1., -1., -1., -1.,-1.],
[ 0.13, -1., -1., -1., -1.,-1.],
[ 0.10, -1., -1., -1., -1.,-1.],
[-1., 0.06, 0.14, 0.087, 0.079,0.],
[ 0., 0.16, 0.10, 0.15, 0.16, 0.],
[-1., -1., 0., 0.004,-1., -1.]])
pl.subplot(111)
pl.imshow(M, origin='lower', interpolation='nearest')
pl.show()
【问题讨论】:
标签: python python-2.7 numpy matplotlib