Skip to content

Bug fix and general touch ups for hist3d_demo example (#1702) #6260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Issue #1702 transpose bugfix
  • Loading branch information
TrishGillett committed Apr 1, 2016
commit 9b9ed321ba4af06ea2fdcaaa9cbbf1026cacbba8
10 changes: 6 additions & 4 deletions examples/mplot3d/hist3d_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Note: np.meshgrid produces arrays in (ny, nx), so flatten is called with 'F'.
# For numpy >= 1.7, this can be avoided by calling meshgrid with indexing='ij'.

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -7,12 +10,11 @@
x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4)

elements = (len(xedges) - 1) * (len(yedges) - 1)
xpos, ypos = np.meshgrid(xedges[:-1] + 0.25, yedges[:-1] + 0.25)
xpos = xpos.flatten('F')
ypos = ypos.flatten('F')
zpos = np.zeros_like(xpos)

xpos = xpos.flatten()
ypos = ypos.flatten()
zpos = np.zeros(elements)
dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = hist.flatten()
Expand Down