Skip to content

Commit

Permalink
Merge branch 'feature/v0.4.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Apr 8, 2023
2 parents 1010890 + bde3db9 commit cdec149
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 2 deletions.
2 changes: 2 additions & 0 deletions colour/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
104 changes: 102 additions & 2 deletions colour/plotting/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,6 +49,7 @@
artist,
plot_chromaticity_diagram_CIE1931,
plot_chromaticity_diagram_CIE1960UCS,
plot_chromaticity_diagram_CIE1976UCS,
filter_passthrough,
override_style,
render,
Expand Down Expand Up @@ -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",
]


Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
(<Figure size ... with 1 Axes>, <...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,
)
1 change: 1 addition & 0 deletions docs/colour.plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
11 changes: 11 additions & 0 deletions utilities/generate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit cdec149

Please sign in to comment.