def plotEdge2D(
mesh2D,
h, real_or_imag='real', ax=None, range_x=None,
range_y=None, sample_grid=None,
logScale=True, clim=None, mirror=False, pcolorOpts=None
):
"""
Create a pcolor plot (a slice in the theta direction) of an edge vector
:param discretize.CylMesh mesh2D: cylindrically symmetric mesh
:param np.ndarray h: edge vector (y components)
:param str real_or_imag: real or imaginary component
:param matplotlib.axes ax: axes
:param numpy.ndarray range_x: x-extent over which we want to plot
:param numpy.ndarray range_y: y-extent over which we want to plot
:param numpy.ndarray sample_grid: x, y spacings at which to re-sample the plotting grid
:param bool logScale: use a log scale for the colorbar?
"""
if ax is None:
fig, ax = plt.subplots(1, 1, figsize=(6, 4))
if len(h) == mesh2D.nE:
vType = 'E'
elif len(h) == mesh2D.nC:
vType = 'CC'
elif len(h) == 2*mesh2D.nC:
vType = 'CCv'
if logScale is True:
pcolorOpts['norm'] = LogNorm()
else:
pcolorOpts = {}
cb = plt.colorbar(
mesh2D.plotImage(
getattr(h, real_or_imag),
view='real', vType=vType, ax=ax,
range_x=range_x, range_y=range_y, sample_grid=sample_grid,
mirror=mirror,
pcolorOpts=pcolorOpts,
)[0], ax=ax
)
if clim is not None:
cb.set_clim(clim)
return ax, cb
评论列表
文章目录