如何从连接矩阵绘制图像? [英] How to plot an image from a connection matrix?
问题描述
我想编写一个脚本来根据连接矩阵创建图像.基本上,只要矩阵中有一个"1",我都希望该区域在图像中被阴影化.例如-
I want to write a script to create an image from a connection matrix. Basically, wherever there is a '1' in the matrix, I want that area to be shaded in the image. For eg -
我使用Photoshop创建了这张图片.但是我有一个很大的数据集,所以我将不得不自动执行该过程.如果有人能指出正确的方向,那将真的很有帮助.
I created this image using Photoshop. But I have a large dataset so I will have to automate the process. It would be really helpful if anyone could point me in the right direction.
编辑
使用脚本后得到的图像是这个.这是由于矩阵很大(19 x 19).有什么办法可以提高这张图片的可见度,使黑白框显得更清晰?
The image that I am getting after using the script is this. This is due to the fact that the matrix is large (19 x 19). Is there any way I can increase the visibility of this image so the black and white boxes appear more clear?
推荐答案
也许您可以尝试一下!
import matplotlib.cm as cm
# Display matrix
plt.imshow(np.random.choice([0, 1], size=100).reshape((10, 10)),cmap=cm.binary)
这篇关于如何从连接矩阵绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!