我一直在试着点画等高线图,以显示数值在统计上有显著意义的位置。然而,当我在意义相同的子图中这样做时,点画看起来会根据填充点画的随机位置而不同。我复制了下面的问题。有没有办法确定点画的位置,使它们在绘制时看起来一样?或者有没有更好的方法来画点图?在
这两个子图绘制的数据完全相同,但点阵看起来不同。在
import numpy as np
from matplotlib import pyplot as plt
#Create some random data
x = np.arange(0,100,1)
x,y = np.meshgrid(x,x)
stipp = 10*np.random.rand(len(x),len(x))
fig =plt.figure(figsize=(12,8))
ax1 = plt.subplot(121)
ax2 = plt.subplot(122)
#Plot stippling
ax1.contourf(x,y,stipp,[0,4],colors='none',hatches='.')
ax2.contourf(x,y,stipp,[0,4],colors='none',hatches='.')
plt.show()
因此,如果有人想知道,最好的方法来点画具有相似统计意义的多个子图是使用上面推荐的散点图,而不是轮廓图。只需确保对数据进行少量采样,这样就不会在彼此相邻的地方有高密度的点。在
相关问题 更多 >
编程相关推荐