diff --git a/colour/plotting/__init__.py b/colour/plotting/__init__.py index 3d36f9a87..b1d696989 100644 --- a/colour/plotting/__init__.py +++ b/colour/plotting/__init__.py @@ -98,6 +98,7 @@ from .temperature import ( # noqa: E402 plot_planckian_locus_in_chromaticity_diagram_CIE1931, plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS, + plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS, ) from .tm3018 import plot_single_sd_colour_rendition_report # noqa: E402 from .volume import ( # noqa: E402 @@ -205,6 +206,7 @@ __all__ += [ "plot_planckian_locus_in_chromaticity_diagram_CIE1931", "plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS", + "plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS", ] __all__ += [ "plot_single_sd_colour_rendition_report", diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index f401db9e5..b7446444d 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -9,6 +9,8 @@ plot_planckian_locus_in_chromaticity_diagram_CIE1931` - :func:`colour.plotting.\ plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS` +- :func:`colour.plotting.\ +plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS` """ from __future__ import annotations @@ -47,6 +49,7 @@ artist, plot_chromaticity_diagram_CIE1931, plot_chromaticity_diagram_CIE1960UCS, + plot_chromaticity_diagram_CIE1976UCS, filter_passthrough, override_style, render, @@ -76,6 +79,7 @@ "plot_planckian_locus_in_chromaticity_diagram", "plot_planckian_locus_in_chromaticity_diagram_CIE1931", "plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS", + "plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS", ] @@ -408,7 +412,8 @@ def CCT_D_uv_to_plotting_colourspace(CCT_D_uv): def plot_planckian_locus_in_chromaticity_diagram( illuminants: str | Sequence[str], chromaticity_diagram_callable: Callable = plot_chromaticity_diagram, - method: Literal["CIE 1931", "CIE 1960 UCS"] | str = "CIE 1931", + method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + | str = "CIE 1931", annotate_kwargs: dict | List[dict] | None = None, plot_kwargs: dict | List[dict] | None = None, **kwargs: Any, @@ -485,7 +490,9 @@ def plot_planckian_locus_in_chromaticity_diagram( :alt: plot_planckian_locus_in_chromaticity_diagram """ - method = validate_method(method, ["CIE 1931", "CIE 1960 UCS"]) + method = validate_method( + method, ["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] + ) cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] @@ -531,6 +538,18 @@ def xy_to_ij(xy: NDArrayFloat) -> NDArrayFloat: bounding_box = (-0.1, 0.7, -0.2, 0.6) + elif method == "CIE 1976 UCS": + + def xy_to_ij(xy: NDArrayFloat) -> NDArrayFloat: + """ + Convert given *CIE xy* chromaticity coordinates to *ij* + chromaticity coordinates. + """ + + return xy_to_Luv_uv(xy) + + bounding_box = (-0.1, 0.7, -0.1, 0.7) + annotate_settings_collection = [ { "annotate": True, @@ -767,3 +786,84 @@ def plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS( plot_kwargs=plot_kwargs, **settings, ) + + +@override_style() +def plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS( + illuminants: str | Sequence[str], + chromaticity_diagram_callable_CIE1976UCS: Callable = ( + plot_chromaticity_diagram_CIE1976UCS + ), + annotate_kwargs: dict | List[dict] | None = None, + plot_kwargs: dict | List[dict] | None = None, + **kwargs: Any, +) -> Tuple[plt.Figure, plt.Axes]: + """ + Plot the *Planckian Locus* and given illuminants in + *CIE 1976 UCS Chromaticity Diagram*. + + Parameters + ---------- + illuminants + Illuminants to plot. ``illuminants`` elements can be of any + type or form supported by the + :func:`colour.plotting.common.filter_passthrough` definition. + chromaticity_diagram_callable_CIE1976UCS + Callable responsible for drawing the + *CIE 1976 UCS Chromaticity Diagram*. + annotate_kwargs + Keyword arguments for the :func:`matplotlib.pyplot.annotate` + definition, used to annotate the resulting chromaticity coordinates + with their respective spectral distribution names. ``annotate_kwargs`` + can be either a single dictionary applied to all the arrows with same + settings or a sequence of dictionaries with different settings for each + spectral distribution. The following special keyword arguments can also + be used: + + - ``annotate`` : Whether to annotate the spectral distributions. + plot_kwargs + Keyword arguments for the :func:`matplotlib.pyplot.plot` definition, + used to control the style of the plotted illuminants. ``plot_kwargs`` + can be either a single dictionary applied to all the plotted + illuminants with the same settings or a sequence of dictionaries with + different settings for eachplotted illuminant. + + Other Parameters + ---------------- + kwargs + {:func:`colour.plotting.artist`, + :func:`colour.plotting.diagrams.plot_chromaticity_diagram`, + :func:`colour.plotting.temperature.plot_planckian_locus`, + :func:`colour.plotting.temperature.\ +plot_planckian_locus_in_chromaticity_diagram`, + :func:`colour.plotting.render`}, + See the documentation of the previously listed definitions. + + Returns + ------- + :class:`tuple` + Current figure and axes. + + Examples + -------- + >>> plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS( + ... ["A", "C", "E"] + ... ) # doctest: +ELLIPSIS + (
, <...Axes...>) + + .. image:: ../_static/Plotting_\ +Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1976UCS.png + :align: center + :alt: plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS + """ + + settings = dict(kwargs) + settings.update({"method": "CIE 1976 UCS"}) + + return plot_planckian_locus_in_chromaticity_diagram( + illuminants, + chromaticity_diagram_callable_CIE1976UCS, + annotate_kwargs=annotate_kwargs, + plot_kwargs=plot_kwargs, + **settings, + ) diff --git a/docs/colour.plotting.rst b/docs/colour.plotting.rst index 8c068c9c7..4514172b6 100644 --- a/docs/colour.plotting.rst +++ b/docs/colour.plotting.rst @@ -262,6 +262,7 @@ Colour Temperature & Correlated Colour Temperature plot_planckian_locus_in_chromaticity_diagram_CIE1931 plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS + plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS **Ancillary Objects** diff --git a/utilities/generate_plots.py b/utilities/generate_plots.py index 68d52b70d..61f75be8a 100755 --- a/utilities/generate_plots.py +++ b/utilities/generate_plots.py @@ -68,6 +68,7 @@ plot_multi_sds, plot_planckian_locus_in_chromaticity_diagram_CIE1931, plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS, + plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS, plot_pointer_gamut, plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931, plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS, @@ -997,6 +998,16 @@ def generate_documentation_plots(output_directory: str): )[0] ) + arguments["filename"] = os.path.join( + output_directory, + "Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1976UCS.png", + ) + plt.close( + plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS( + ["A", "B", "C"], **arguments + )[0] + ) + arguments["filename"] = os.path.join( output_directory, "Plotting_Plot_Single_SD_Colour_Rendition_Report_Full.png",