imshow¶
- fcp.imshow(**kwargs)¶
Image show plotting function.
- Parameters
df (DataFrame | numpy array) – DataFrame or numpy array containing 2D row/column image data to plot [when passing a numpy array it is automatically converted to a DataFrame]
- Keyword Arguments
cfa (str) – Color-filter array pattern that is used to split data from a Bayer image into separate color planes. Defaults to None. More details
cmap (bool) – Name of a color map to apply to the plot. Defaults to gray. More details
imshow_interp|interp (str) – imshow interpolation scheme [see matplotlib docs for more details]. Defaults to ‘none’.
stretch (float|list) – Calculate “stretch” times the standard deviation above and below the mean to set new z-limits. Can be a single value used as +/- limits or a two-value list for the lower/upper multiplier values. Defaults to None. More details
Examples
Basic:
>>> import fivecentplots as fcp >>> from pathlib import Path >>> import pandas as pd >>> import imageio >>> # Read an image from the world-wide web >>> url = 'https://imagesvc.meredithcorp.io/v3/mm/image?q=85&c=sc&rect=0%2C214%2C2000%2C1214&' >>> + 'poi=%5B920%2C546%5D&w=2000&h=1000&url=https%3A%2F%2Fstatic.onecms.io%2Fwp-content%2Fuploads' >>> + '%2Fsites%2F47%2F2020%2F10%2F07%2Fcat-in-pirate-costume-380541532-2000.jpg' >>> imgr = imageio.imread(url) >>> # Convert to grayscale >>> img = fcp.utilities.img_grayscale(imgr) >>> fcp.imshow(img, ax_size=[600, 600])
With +/- 3 sigma contrast stretching:
>>> uu = img.stack().mean() >>> ss = img.stack().std() >>> fcp.imshow(img, cmap='inferno', cbar=True, ax_size=[600, 600], zmin=uu-3*ss, zmax=uu+3*ss)