Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
alpha : float (optional)
The alpha value for the plot. This will help adjust the transparency of the
plot to the desired level.
norm : matplotlib Normalize object (Optional)
The normalized boundaries for custom values coloring. NOTE: For this argument
to work, the scale argument MUST be set to false. Otherwise, the values will
just be scaled from 0-255
Returns
----------
ax : matplotlib.axes object
The axes object(s) associated with the plot.
"""
if scale:
arr_im = es.bytescale(arr_im)
im = ax.imshow(
arr_im,
cmap=cmap,
vmin=vmin,
vmax=vmax,
extent=extent,
alpha=alpha,
norm=norm,
)
if title:
ax.set(title=title)
if cbar:
colorbar(im)
ax.set(xticks=[], yticks=[])
# Index bands for plotting and clean up data for matplotlib
rgb_bands = arr[rgb, :, :]
if stretch:
rgb_bands = _stretch_im(rgb_bands, str_clip)
# If type is masked array - add alpha channel for plotting
if ma.is_masked(rgb_bands):
# Build alpha channel
mask = ~(np.ma.getmask(rgb_bands[0])) * 255
# Add the mask to the array & swap the axes order from (bands,
# rows, columns) to (rows, columns, bands) for plotting
rgb_bands = np.vstack(
(es.bytescale(rgb_bands), np.expand_dims(mask, axis=0))
).transpose([1, 2, 0])
else:
# Index bands for plotting and clean up data for matplotlib
rgb_bands = es.bytescale(rgb_bands).transpose([1, 2, 0])
# Then plot. Define ax if it's undefined
show = False
if ax is None:
fig, ax = plt.subplots(figsize=figsize)
show = True
ax.imshow(rgb_bands, extent=extent)
ax.set_title(title)
ax.set(xticks=[], yticks=[])
# Multipanel won't work if plt.show is called prior to second plot def
if stretch:
rgb_bands = _stretch_im(rgb_bands, str_clip)
# If type is masked array - add alpha channel for plotting
if ma.is_masked(rgb_bands):
# Build alpha channel
mask = ~(np.ma.getmask(rgb_bands[0])) * 255
# Add the mask to the array & swap the axes order from (bands,
# rows, columns) to (rows, columns, bands) for plotting
rgb_bands = np.vstack(
(es.bytescale(rgb_bands), np.expand_dims(mask, axis=0))
).transpose([1, 2, 0])
else:
# Index bands for plotting and clean up data for matplotlib
rgb_bands = es.bytescale(rgb_bands).transpose([1, 2, 0])
# Then plot. Define ax if it's undefined
show = False
if ax is None:
fig, ax = plt.subplots(figsize=figsize)
show = True
ax.imshow(rgb_bands, extent=extent)
ax.set_title(title)
ax.set(xticks=[], yticks=[])
# Multipanel won't work if plt.show is called prior to second plot def
if show:
plt.show()
return ax