cachai.utilities.colormapped_patch
- cachai.utilities.colormapped_patch(patch, map_matrix, ax=None, colormap='coolwarm', zorder=5, alpha=0.5, rasterized=False)[source]
Applies a colormap to a patch object using a precomputed map matrix, creating a color-filled shape.
- Parameters
- patch
matplotlib.patches.Patchand similar Matplotlib patch object to be filled with colors.
- map_matrix
numpy.ndarray 2D array containing color values for the mapping.
- patch
- Returns
matplotlib.image.AxesImage- Other Parameters
- ax
matplotlib.axes.Axes Axes object where the patch will be drawn (default: current axes).
- colormap
strormatplotlib.colors.LinearSegmentedColormap Matplotlib colormap to use.
- zorder
int Rendering order layer for the patch.
- alpha
float Transparency level of the filled patch.
- rasterized
bool Whether to rasterize the patch for better performance.
- ax
Examples
import cachai.utilities as chu import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Circle # Create a circular patch circle = Circle((0.5, 0.5), 0.3) # Generate a simple gradient map gradient = np.linspace(-1, 1, 400).reshape(20, 20) fig, ax = plt.subplots() ax.add_patch(circle) chu.colormapped_patch(circle, gradient, ax=ax) plt.show()