curvelets.plot package¶
- curvelets.plot.create_colorbar(im, ax=None, size=0.05, pad=0.1, orientation='vertical')¶
Create a colorbar. Divides axis and attaches a colorbar to it.
- Parameters:
im (
AxesImage) – Image from which the colorbar will be created. Commonly the output ofplt.imshow.ax (
Axes|None) – Axis which to split. Usesplt.gcaif None.size (
float) – Size of split, by default 0.05. Effectively sets the size of the colorbar.pad (
float) – Padding between colorbar axis and input axis, by default 0.1.orientation (
str) – Orientation of the colorbar, by default “vertical”.
- Return type:
- Returns:
Examples
>>> import matplotlib.pyplot as plt >>> from matplotlib.ticker import MultipleLocator >>> from curvelets.plot import create_colorbar >>> fig, ax = plt.subplots() >>> im = ax.imshow([[0]], vmin=-1, vmax=1, cmap="gray") >>> cax, cb = create_colorbar(im, ax) >>> cax.yaxis.set_major_locator(MultipleLocator(0.1)) >>> print(cb.vmin) -1.0
- curvelets.plot.create_inset_axes_grid(ax, rows=1, cols=1, height=0.5, width=0.5, squeeze=True, kwargs_inset_axes=None)¶
Create a grid of insets.
The input axis will be overlaid with a grid of insets. Numbering of the axes is top to bottom (rows) and left to right (cols).
- Parameters:
ax (
Axes) – Input axis.rows (
int) – Number of rows, by default 1.cols (
int) – Number of columns, by default 1.width (
float) – Width of each axis, as a percentage ofcols, by default 0.5.height (
float) – Height of each axis, as a percentage ofrows, by default 0.5.squeeze (
bool) – If True, removes singleton dimensions likeplt.subplots.kwargs_inset_axes (
dict[str,Any] |None) – Arguments to be passed tomatplotlib.axes.Axes.inset_axes.
- Returns:
Array of
Axesshaped(rows, cols).- Return type:
Examples
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from curvelets.plot import create_inset_axes_grid >>> fig, ax = plt.subplots(figsize=(6, 6)) >>> ax.imshow([[0]], extent=[-2, 2, 2, -2], vmin=-1, vmax=1, cmap="gray") >>> rows, cols = 2, 3 >>> inset_axes = create_inset_axes_grid( >>> ax, >>> rows, >>> cols, >>> width=0.5, >>> height=0.5, >>> kwargs_inset_axes={"projection": "polar"}, >>> ) >>> nscales = 4 >>> lw = 0.1 >>> for irow in range(rows): >>> for icol in range(cols): >>> for iscale in range(1, nscales): >>> inset_axes[irow][icol].bar( >>> x=0, >>> height=lw, >>> width=2 * np.pi, >>> bottom=((iscale + 1) - 0.5 * lw) / (nscales - 1), >>> color="r", >>> ) >>> inset_axes[irow][icol].set(title=f"Row, Col: ({irow}, {icol})") >>> inset_axes[irow][icol].axis("off")
- curvelets.plot.despine(ax)¶
Remove the top and right spines from plot(s).
- curvelets.plot.overlay_arrows(vectors, ax, arrowprops=None)¶
Overlay arrows on an axis.
- Parameters:
vectors (
NDArray[generic]) – Array shaped(rows, cols, 2), corresponding to a 2D vector field.ax (
Axes) – Axis on which to overlay the arrows.arrowprops (
dict[str,Any] |None) – Arrow properties, to be passed tomatplotlib.pyplot.annotate. By default will be set to{"facecolor": "black", "shrink": 0.05}.
- Return type:
Examples
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from curvelets.plot import overlay_arrows >>> fig, ax = plt.subplots(figsize=(8, 10)) >>> ax.imshow([[0]], vmin=-1, vmax=1, extent=[0, 1, 1, 0], cmap="gray") >>> rows, cols = 3, 4 >>> kvecs = np.array( >>> [ >>> [(1 + x, x * y) for x in (0.5 + np.arange(cols)) / cols] >>> for y in (0.5 + np.arange(rows)) / rows >>> ] >>> ) >>> overlay_arrows( >>> 0.05 * kvecs, >>> ax, >>> arrowprops=dict( >>> facecolor="r", >>> shrink=0.05, >>> width=10 / cols, >>> headwidth=10, >>> headlength=10, >>> ), >>> )
- curvelets.plot.overlay_disk(c_struct, ax=None, linewidth=5, linecolor='r', cmap='plasma', vmin=None, vmax=None, direction='normal', origin='upper')¶
Overlay a curvelet structure onto its locations on a multiscale, multidirectional disk.
Its intended usage is to display various scalars derived from curvelet wedges of a certain image with a disk display.
- Parameters:
c_struct (
list[list[list[float]]]) – A scale for every curvelet wedge.ax (
Axes|None) – Axis on which to overlay the disk. Usesplt.gcaif None.linewidth (
float) – Width of line separating scales as a percentage of a single scale height, by default 5. Set to zero to disable.linecolor (
str) – Color of line separating scales, by default “r”.cmap (
str|Colormap) – Colormap or name of colormap, by default"plasma".vmin (
float|None) – Data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data.vmax (
float|None) – Data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data.direction (
str) – “tangent” or, by default “normal”origin (
str) – “upper” or “lower”, by default “upper”. Matchesplt.imshowdefault where the vertical axis increases downwards.
- Returns:
Axis used.
- Return type:
Notes
Wedge angles are frequency angles of the underlying array (cycles per sample along each axis) — the UDCT has no notion of physical sample spacing. When overlaying the disk on an image, display the image with square pixels (index extents with the default
imshowaspect, or physical extents withaspect=dy/dx) so that on-screen directions match the disk.