私は散布図上に多くのデータを持っています。最終結果は数百万点になります。これはスキャッタグラフ上では意味をなさないほどです - ここで説明するように、2Dヒストグラムに変換し、等高線プロットを描きたいhttps://micropore.wordpress.com/2011/10/01/2d-density-plot-or-2d-histogram/Pyplotの輪郭がxyに沿って反転されます
これは私が使用しているコードと似ています。同じ問題
import numpy
import matplotlib.pyplot as pyplot
def convert_edges_to_centres(edges):
centres = numpy.empty(len(edges)-1)
for i in range(len(centres)):
centres[i] = (edges[i+1] - edges[i])/2 + edges[i]
return centres
x = numpy.random.normal(0,1,50000)
print numpy.amin(x),numpy.amax(x)
y = numpy.random.beta(2,5,50000)
print numpy.amin(y),numpy.amax(y)
H,xedges,yedges=numpy.histogram2d(x,y,bins=25)
xcentres,ycentres=convert_edges_to_centres(xedges),convert_edges_to_centres(yedges)
print numpy.shape(H)
print numpy.shape(xedges),numpy.shape(xcentres)
print numpy.shape(yedges),numpy.shape(ycentres)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
ax = pyplot.axes()
ax.scatter(x,y)
ax.contour(H,extent=extent)
pyplot.show()
しかし、等高線は、それがおそらくXYに沿って反転しているように見えるflipped-さ:
私は、これはおそらく、簡単に解決されていますが、私は何をうまくすることはできません実現プロ傷ついている!
私も構文pyplot.contour(x,y,z)
を使用してプロットしてみましたように私は、中convert_edges_to_centres機能を置くが、それはうまくいきませんでしたどちらか
をプロットしたいことがありますが、[この](https://stackoverflow.com/questions/18835037/matplotlib-contour-input-array-order)で見たことがありますか? – BrenBarn
ありがとう - 私はそれを見ていない。私はそれが解決するかわからない – user30865