如果你想拥有类似imshow
例子是你链接到,但不同的坐标轴,您可能需要使用extent
关键字imshow
:
import numpy as np
import matplotlib.pyplot as plt
# some random data (10x10)
image = np.random.uniform(size=(10, 10))
plt.figure()
# draw the pixel image
# interpolation='nearest': draw blocky pixels, do not smooth
# cmap=pl.cm.gray: use gray scale colormap (autoscale, no vmin or vmax defined
# origin='lower': draw first row of the array to the bottom if the image
# extent=[-3,3,-10,10]: draw the image so that it covers area (-3,-10)..(3,10)
plt.imshow(image, cmap=plt.cm.gray, interpolation='nearest', origin='lower', extent=[-3,3,-10,10])
# this is needed to make the pixels non-square if needed
plt.axis('normal')
plt.colorbar()
plt.show()
这种方式,你可以创建“像素“其大小是你想要什么:
当然,你可以画出更多的信息到同巴解组织如果你想通过使用plot
或其他东西。
image
这是一个标量数组,它的着色由cmap
定义,但如果您想做更有趣的着色,它也可能是RGB或RGBA值的数组。例如:
How to create colormap of confidence estimates for k-Nearest Neighbor Classification
如果你想在你的地图透明区域,把nan
值到image
。
来源
2014-06-28 09:33:44
DrV
这不就是['pcolor(X,Y,C)'](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pcolor)吗? –
你能举个例子吗?我真的不喜欢写在你提供的链接中的文档..请 – MycrofD
我不能在评论中给出一个例子。但是,如果您在问题中提供了'X','Y'和'C'的示例,并且具体描述了这些值的期望结果,那么我或其他人可能会提供更自信的答案。 –