Skip to content

Instantly share code, notes, and snippets.

@d-v-b
Created January 19, 2015 21:56
Show Gist options
  • Save d-v-b/4f05b6fb265b4af37ece to your computer and use it in GitHub Desktop.
Save d-v-b/4f05b6fb265b4af37ece to your computer and use it in GitHub Desktop.
def projFigure(vol, limits, plDims=[16,10,5], zscale=5, colors='gray',title=None):
x,y,z = plDims
grid = (y+z,x+z)
zRat = zscale*(float(y)/z)
plt.figure(figsize=grid[-1::-1])
# plot the x-y view (top-down)
ax1 = plt.subplot2grid(grid,(0,0),rowspan=y,colspan=x)
plt.imshow(vol.max(0) + vol.min(0),clim=limits,cmap=colors,origin='leftcorner',interpolation='Nearest')
ax1.axes.xaxis.set_ticklabels([])
if title:
plt.title(title)
# plot the x-z view (side-on)
ax2 = plt.subplot2grid(grid,(y,0),rowspan=z,colspan=x)
plt.imshow(vol.max(1)+vol.min(1),aspect=zRat,clim=limits,cmap=colors,origin='leftcorner',interpolation='Nearest')
# plot the y-z view (head-on)
ax3 = plt.subplot2grid(grid,(0,x),rowspan=y,colspan=z)
plt.imshow((vol.max(2)+vol.min(2)).T,aspect=1/zRat,clim=limits,cmap=colors,origin='leftcorner',interpolation='Nearest')
ax3.axes.yaxis.set_ticklabels([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment