<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1985" rel="nofollow">http://projects.scipy.org/numpy/ticket/1985</a> on 2011-11-22 by trac user gsiisg, assigned to unknown.</em></p>
<p dir="auto">I notice that when I plot two variables, the x and y axis are flipped according to the online example, so I did a simple distribution of points</p>
<p dir="auto">x=np.array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10,  1])<br>
y=np.array([ 10,  20,  30,  40,  50,  60,  70,  80,  90, 100, 100])<br>
H, yedges, xedges = np.histogram2d(y,x)<br>
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]<br>
pylab.imshow(H, extent=extent, interpolation='nearest',origin='lower',aspect='auto')</p>
<p dir="auto">I had to enter into histgram2d() the "y" before the "x" to get the graph to come out as expected.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1830" rel="nofollow">http://projects.scipy.org/numpy/ticket/1830</a> on 2011-05-14 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/samtygier/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/samtygier">@samtygier</a>, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pv/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pv">@pv</a>.</em></p>
<p dir="auto">the matplotlib example in <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html</a> plots the data with the axis the wrong way. i think this is mostly the fault of imshow working in backwards coordinates.</p>
<p dir="auto">the lines should be:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.imshow(H.transpose(), extent=extent, interpolation='nearest', origin=&quot;lower&quot;)"><pre class="notranslate"><code class="notranslate">extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.imshow(H.transpose(), extent=extent, interpolation='nearest', origin="lower")
</code></pre></div>
<p dir="auto">test script (broken, as per numpy docs):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="x = np.array([2,   2, -1, -1, -0.2])
y = np.array([1,-1.1,  1, -1,  0.5])
H, xedges, yedges = np.histogram2d(x,y, bins=(50, 50))
extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
plt.imshow(H, extent=extent, interpolation='nearest')
plt.show()"><pre class="notranslate"><code class="notranslate">x = np.array([2,   2, -1, -1, -0.2])
y = np.array([1,-1.1,  1, -1,  0.5])
H, xedges, yedges = np.histogram2d(x,y, bins=(50, 50))
extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
plt.imshow(H, extent=extent, interpolation='nearest')
plt.show()
</code></pre></div>
<p dir="auto">test script (fixed):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="x = np.array([2,   2, -1, -1, -0.2])
y = np.array([1,-1.1,  1, -1,  0.5])
H, xedges, yedges = np.histogram2d(x,y, bins=(50, 50))
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.imshow(H.transpose(), extent=extent, interpolation='nearest', origin=&quot;lower&quot;)
plt.show()"><pre class="notranslate"><code class="notranslate">x = np.array([2,   2, -1, -1, -0.2])
y = np.array([1,-1.1,  1, -1,  0.5])
H, xedges, yedges = np.histogram2d(x,y, bins=(50, 50))
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.imshow(H.transpose(), extent=extent, interpolation='nearest', origin="lower")
plt.show()
</code></pre></div>