• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

colour-science / colour / 18370061804

09 Oct 2025 08:19AM UTC coverage: 76.753% (-22.6%) from 99.349%
18370061804

push

github

KelSolaar
Merge branch 'feature/v0.4.7' into develop

32663 of 42556 relevant lines covered (76.75%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.33
/colour/plotting/corresponding.py
1
"""
2
Corresponding Chromaticities Prediction Plotting
3
================================================
4

5
Define the corresponding chromaticities prediction plotting objects.
6

7
-   :func:`colour.plotting.plot_corresponding_chromaticities_prediction`
8
"""
9

10
from __future__ import annotations
×
11

12
import typing
×
13

14
if typing.TYPE_CHECKING:
15
    from matplotlib.figure import Figure
16
    from matplotlib.axes import Axes
17

18
from colour.corresponding import (
×
19
    CorrespondingColourDataset,
20
    corresponding_chromaticities_prediction,
21
)
22

23
if typing.TYPE_CHECKING:
24
    from colour.hints import Any, Dict, Literal, Tuple
25

26
from colour.hints import cast
×
27
from colour.plotting import (
×
28
    CONSTANTS_COLOUR_STYLE,
29
    artist,
30
    override_style,
31
    plot_chromaticity_diagram_CIE1976UCS,
32
    render,
33
)
34
from colour.utilities import is_numeric
×
35

36
__author__ = "Colour Developers"
×
37
__copyright__ = "Copyright 2013 Colour Developers"
×
38
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
×
39
__maintainer__ = "Colour Developers"
×
40
__email__ = "colour-developers@colour-science.org"
×
41
__status__ = "Production"
×
42

43
__all__ = [
×
44
    "plot_corresponding_chromaticities_prediction",
45
]
46

47

48
@override_style()
×
49
def plot_corresponding_chromaticities_prediction(
×
50
    experiment: (Literal[1, 2, 3, 4, 6, 8, 9, 11, 12] | CorrespondingColourDataset) = 1,
51
    model: (
52
        Literal[
53
            "CIE 1994",
54
            "CMCCAT2000",
55
            "Fairchild 1990",
56
            "Von Kries",
57
            "Zhai 2018",
58
        ]
59
        | str
60
    ) = "Von Kries",
61
    corresponding_chromaticities_prediction_kwargs: dict | None = None,
62
    **kwargs: Any,
63
) -> Tuple[Figure, Axes]:
64
    """
65
    Plot the corresponding chromaticities prediction for the specified
66
    chromatic adaptation model.
67

68
    Parameters
69
    ----------
70
    experiment
71
        *Breneman (1987)* experiment number or
72
        :class:`colour.CorrespondingColourDataset` class instance.
73
    model
74
        Corresponding chromaticities prediction model name.
75
    corresponding_chromaticities_prediction_kwargs
76
        Keyword arguments for the
77
        :func:`colour.corresponding_chromaticities_prediction` definition.
78

79
    Other Parameters
80
    ----------------
81
    kwargs
82
        {:func:`colour.plotting.artist`,
83
        :func:`colour.plotting.diagrams.plot_chromaticity_diagram`,
84
        :func:`colour.plotting.render`},
85
        See the documentation of the previously listed definitions.
86

87
    Returns
88
    -------
89
    :class:`tuple`
90
        Current figure and axes.
91

92
    Examples
93
    --------
94
    >>> plot_corresponding_chromaticities_prediction(1, "Von Kries")
95
    ... # doctest: +ELLIPSIS
96
    (<Figure size ... with 1 Axes>, <...Axes...>)
97

98
    .. image:: ../_static/Plotting_\
99
Plot_Corresponding_Chromaticities_Prediction.png
100
        :align: center
101
        :alt: plot_corresponding_chromaticities_prediction
102
    """
103

104
    if corresponding_chromaticities_prediction_kwargs is None:
1✔
105
        corresponding_chromaticities_prediction_kwargs = {}
1✔
106

107
    settings: Dict[str, Any] = {"uniform": True}
1✔
108
    settings.update(kwargs)
1✔
109

110
    _figure, axes = artist(**settings)
1✔
111

112
    name = (
1✔
113
        f"Experiment {experiment}"
114
        if is_numeric(experiment)
115
        else cast("CorrespondingColourDataset", experiment).name
116
    )
117
    title = (
1✔
118
        f"Corresponding Chromaticities Prediction - {model} - {name} - "
119
        "CIE 1976 UCS Chromaticity Diagram"
120
    )
121

122
    settings = {"axes": axes, "title": title}
1✔
123
    settings.update(kwargs)
1✔
124
    settings["show"] = False
1✔
125

126
    plot_chromaticity_diagram_CIE1976UCS(**settings)
1✔
127

128
    results = corresponding_chromaticities_prediction(
1✔
129
        experiment, model, **corresponding_chromaticities_prediction_kwargs
130
    )
131

132
    for result in results:
1✔
133
        _name, uv_t, uv_m, uv_p = result.values
1✔
134
        axes.arrow(
1✔
135
            uv_t[0],
136
            uv_t[1],
137
            uv_p[0] - uv_t[0] - 0.1 * (uv_p[0] - uv_t[0]),
138
            uv_p[1] - uv_t[1] - 0.1 * (uv_p[1] - uv_t[1]),
139
            color=CONSTANTS_COLOUR_STYLE.colour.dark,
140
            head_width=0.005,
141
            head_length=0.005,
142
            zorder=CONSTANTS_COLOUR_STYLE.zorder.midground_annotation,
143
        )
144
        axes.plot(
1✔
145
            uv_t[0],
146
            uv_t[1],
147
            "o",
148
            color=CONSTANTS_COLOUR_STYLE.colour.brightest,
149
            markeredgecolor=CONSTANTS_COLOUR_STYLE.colour.dark,
150
            markersize=(
151
                CONSTANTS_COLOUR_STYLE.geometry.short * 6
152
                + CONSTANTS_COLOUR_STYLE.geometry.short * 0.75
153
            ),
154
            markeredgewidth=CONSTANTS_COLOUR_STYLE.geometry.short * 0.75,
155
            zorder=CONSTANTS_COLOUR_STYLE.zorder.foreground_line,
156
        )
157
        axes.plot(
1✔
158
            uv_m[0],
159
            uv_m[1],
160
            "^",
161
            color=CONSTANTS_COLOUR_STYLE.colour.brightest,
162
            markeredgecolor=CONSTANTS_COLOUR_STYLE.colour.dark,
163
            markersize=(
164
                CONSTANTS_COLOUR_STYLE.geometry.short * 6
165
                + CONSTANTS_COLOUR_STYLE.geometry.short * 0.75
166
            ),
167
            markeredgewidth=CONSTANTS_COLOUR_STYLE.geometry.short * 0.75,
168
            zorder=CONSTANTS_COLOUR_STYLE.zorder.foreground_line,
169
        )
170
        axes.plot(
1✔
171
            uv_p[0],
172
            uv_p[1],
173
            "^",
174
            color=CONSTANTS_COLOUR_STYLE.colour.dark,
175
            zorder=CONSTANTS_COLOUR_STYLE.zorder.foreground_line,
176
        )
177

178
    settings.update(
1✔
179
        {
180
            "show": True,
181
            "bounding_box": (-0.1, 0.7, -0.1, 0.7),
182
        }
183
    )
184
    settings.update(kwargs)
1✔
185

186
    return render(**settings)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc