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, optional) – Axis which to split. Usesplt.gcaif None.size (
float, optional) – Size of split, by default 0.05. Effectively sets the size of the colorbar.pad (
float, optional) – Padding between colorbar axis and input axis, by default 0.1.orientation (
str, optional) – 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, optional) – Number of rows, by default 1.cols (
int, optional) – Number of columns, by default 1.width (
float, optional) – Width of each axis, as a percentage ofcols, by default 0.5.height (
float, optional) – Height of each axis, as a percentage ofrows, by default 0.5.squeeze (
float) – If True, removes singleton dimensions likeplt.subplots.kwargs_inset_axes (dict[str, Any], optional) – Arguments to be passed to
matplotlib.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) – Array shaped(rows, cols, 2), corresponding to a 2D vector field.ax (
Axes) – Axis on which to overlay the arrows.arrowprops (
dict, optional) – 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='turbo', vmin=None, vmax=None, direction='normal')¶
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, optional) – Axis on which to overlay the disk. Usesplt.gcaif None.linewidth (float, optional) – Width of line separating scales as a percentage of a single scale height, by default 5. Set to zero to disable.
linecolor (str, optional) – Color of line separating scales, by default “r”.
cmap (str, optional) – Colormap, by default
"turbo".vmin (float, optional) – Data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data.
vmax (float, optional) – Data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data.
direction (str, optional) – “tangent” or, by default “normal”
- Returns:
Axis used.
- Return type: