def plot(self, slice_index=None, handle=False, figure=None, ax_xy=None,
vmin=None, vmax=None, cmap=None):
import matplotlib.pyplot as plt
from matplotlib import ticker
ax_xy, ax_xz, ax_yz, ax_cb = self.get_plot_axes(figure, ax_xy)
if figure is None:
figure = ax_xy.get_figure()
if slice_index is None:
slice_index = tuple(int(v) for v in
(self.nx/2, self.ny/2, self.nz/2))
if slice_index == 'max':
slice_index = self.get_ijk_max()
if slice_index == 'min':
slice_index = self.get_ijk_min()
hnd = ax_xy.imshow(np.transpose(self.array[:, :, slice_index[2]]),
vmin=vmin, vmax=vmax, cmap=cmap,
origin='lower', extent=self.get_xy_extent(),
zorder=-10)
ax_xy.set_adjustable('box-forced')
ax_xz.imshow(np.transpose(self.array[:, slice_index[1], :]),
vmin=vmin, vmax=vmax, cmap=cmap,
origin='lower', extent=self.get_xz_extent(),
aspect='auto', zorder=-10)
ax_xz.set_adjustable('box-forced')
ax_yz.imshow(self.array[slice_index[0], :, :],
vmin=vmin, vmax=vmax, cmap=cmap,
origin='lower', extent=self.get_zy_extent(),
aspect='auto', zorder=-10)
ax_yz.set_adjustable('box-forced')
x_slice, y_slice, z_slice = self.get_xyz(*slice_index)
ax_xy.axhline(y_slice, color='w', linestyle='dashed', zorder=-1)
ax_xy.axvline(x_slice, color='w', linestyle='dashed', zorder=-1)
ax_xz.axhline(z_slice, color='w', linestyle='dashed', zorder=-1)
ax_yz.axvline(z_slice, color='w', linestyle='dashed', zorder=-1)
fmt = '%.1e' if self.max() <= 0.01 else '%.2f'
cb = figure.colorbar(hnd, cax=ax_cb, orientation='horizontal',
format=fmt)
cb.locator = ticker.LinearLocator(numticks=3)
cb.update_ticks()
if handle:
return (ax_xy, ax_xz, ax_yz), cb
else:
plt.show()
评论列表
文章目录