spyrit.misc.color.wavelength_to_colormap

spyrit.misc.color.wavelength_to_colormap(wav, gamma=0.6)[source]

Creates a linear Matplotlib colormap that transitions from black to a specific color corresponding to a given electromagnetic wavelength.

Args:

wav (float): The wavelength in nanometers (nm) to determine the target color. Typically, this would be in the visible spectrum range (~380 to 780 nm).

gamma (float, optional): The gamma correction factor applied when calculating the RGB color from the wavelength. Defaults to 0.6.

Returns:

matplotlib.colors.LinearSegmentedColormap: A custom colormap object named ‘DarkToColor’ that spans from black at the low end (0.0) to the calculated wavelength-based color at the high end (1.0).

Example:
>>> cmap = wavelength_to_colormap(550, gamma=0.8) # Green color at 550nm
>>> print(cmap)
<matplotlib.colors.LinearSegmentedColormap object at ...>