2016-04-23 93 views

回答

0

您可能会发现代码在这里一个例子: Matplotlib Gallery, Scatter plot

你可以提供你的代码产生了更详细的讨论。

+0

感谢您的回复,但他们使用的是plt.scatter(),而不是matshow()。 – user3787097

0

尽管我没有找到任何改变matshow方块形状的东西,但您可以使用scatter来绘制您想要的东西。

import numpy as np 
import matplotlib.pyplot as plt 
matrix = np.random.rand(5,6) 
#now your points and values are: 
nx,ny = matrix.shape 
X,Y,values = zip(*[ (i,j,matrix[i,j]) for i in range(nx) for j in range(ny) ]) 
fig = plt.figure() 
ax = fig.add_subplot(111) 
ax.scatter(X,Y,s=5000,c=values,cmap='viridis',alpha=0.5) 

也许你想要一个小点的大小,但是本作的剧情看起来更加花哨。 ![matplotlib scatter as matshow] 1