Skip to content

Add wavelengths_strip to plotting functions with wavelengths on x axis.#1401

Open
lassefschmidt wants to merge 1 commit intocolour-science:developfrom
lassefschmidt:feature/plot_wavelength_on_xaxis
Open

Add wavelengths_strip to plotting functions with wavelengths on x axis.#1401
lassefschmidt wants to merge 1 commit intocolour-science:developfrom
lassefschmidt:feature/plot_wavelength_on_xaxis

Conversation

@lassefschmidt
Copy link
Copy Markdown
Contributor

Summary

Add a boolean parameter to plotting functions with wavelength on x-axis called wavelengths_strip to add the visible spectrum to the xaxis. If wavelengths go beyond visible interval (UV or IR), those areas are shown for visual cleanliness with a striped gray filling.

See wavelengths_strip_plots.html for how plots would look like with the argument activated.

As you can see e.g. for the very first plot (below minimal code example), the hues of the wavelengths strip might be slightly different to that of the spectrum itself as I wanted to desaturate the RGB colours of the wavelengths strip a bit. This can be easily changed but I felt that this made the plots visually too heavy. Happy to revert if wanted.

import numpy as np

def gaussian(x, mu, sigma):
    x = np.asarray(x, dtype=float)
    return np.exp(-0.5 * ((x - mu) / sigma) ** 2)

def make_red_reflectance(start=300, stop=1000, step=10):
    wl = np.arange(start, stop + step, step)

    # Low reflectance in blue/green, rising toward red
    r = (
        0.03
        + 0.82 * gaussian(wl, mu=660, sigma=40)
    )
    r = np.clip(r, 0.0, 1.0)

    return {int(w): float(v) for w, v in zip(wl, r)}

data_1 = make_red_reflectance()

from colour import SpectralDistribution
sd_1 = SpectralDistribution(data_1, name="Custom 1")

from colour.plotting import plot_single_sd

plot_single_sd(sd_1, wavelengths_strip=True)

Preflight

Code Style and Quality

  • Unit tests have been implemented and passed.
  • Pyright static checking has been run and passed.
  • Pre-commit hooks have been run and passed.
  • [N/A] New transformations have been added to the Automatic Colour Conversion Graph.
  • [N/A] New transformations have been exported to the relevant namespaces, e.g. colour, colour.models.

Documentation

  • [N/A] New features are documented along with examples if relevant.
  • The documentation is Sphinx and numpydoc compliant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant