Coverage for colour/plotting/notation.py: 100%
21 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""
2Colour Notation Systems Plotting
3================================
5Define the colour notation systems plotting objects.
7- :func:`colour.plotting.plot_single_munsell_value_function`
8- :func:`colour.plotting.plot_multi_munsell_value_functions`
9"""
11from __future__ import annotations
13import typing
15import numpy as np
17if typing.TYPE_CHECKING:
18 from matplotlib.axes import Axes
19 from matplotlib.figure import Figure
21if typing.TYPE_CHECKING:
22 from colour.hints import Any, Callable, Dict, Sequence, Tuple
24from colour.notation import MUNSELL_VALUE_METHODS
25from colour.plotting import filter_passthrough, override_style, plot_multi_functions
27__author__ = "Colour Developers"
28__copyright__ = "Copyright 2013 Colour Developers"
29__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
30__maintainer__ = "Colour Developers"
31__email__ = "colour-developers@colour-science.org"
32__status__ = "Production"
34__all__ = [
35 "plot_single_munsell_value_function",
36 "plot_multi_munsell_value_functions",
37]
40@override_style()
41def plot_single_munsell_value_function(
42 function: Callable | str, **kwargs: Any
43) -> Tuple[Figure, Axes]:
44 """
45 Plot the specified *Munsell* value function.
47 Parameters
48 ----------
49 function
50 *Munsell* value function to plot. ``function`` can be of any type
51 or form supported by the
52 :func:`colour.plotting.common.filter_passthrough` definition.
54 Other Parameters
55 ----------------
56 kwargs
57 {:func:`colour.plotting.artist`,
58 :func:`colour.plotting.plot_multi_functions`,
59 :func:`colour.plotting.render`},
60 See the documentation of the previously listed definitions.
62 Returns
63 -------
64 :class:`tuple`
65 Current figure and axes.
67 Examples
68 --------
69 >>> plot_single_munsell_value_function("ASTM D1535") # doctest: +ELLIPSIS
70 (<Figure size ... with 1 Axes>, <...Axes...>)
72 .. image:: ../_static/Plotting_Plot_Single_Munsell_Value_Function.png
73 :align: center
74 :alt: plot_single_munsell_value_function
75 """
77 settings: Dict[str, Any] = {"title": f"{function} - Munsell Value Function"}
78 settings.update(kwargs)
80 return plot_multi_munsell_value_functions((function,), **settings)
83@override_style()
84def plot_multi_munsell_value_functions(
85 functions: Callable | str | Sequence[Callable | str],
86 **kwargs: Any,
87) -> Tuple[Figure, Axes]:
88 """
89 Plot the specified *Munsell* value functions.
91 Parameters
92 ----------
93 functions
94 *Munsell* value functions to plot. ``functions`` elements can be of
95 any type or form supported by the
96 :func:`colour.plotting.common.filter_passthrough` definition.
98 Other Parameters
99 ----------------
100 kwargs
101 {:func:`colour.plotting.artist`,
102 :func:`colour.plotting.plot_multi_functions`,
103 :func:`colour.plotting.render`},
104 See the documentation of the previously listed definitions.
106 Returns
107 -------
108 :class:`tuple`
109 Current figure and axes.
111 Examples
112 --------
113 >>> plot_multi_munsell_value_functions(["ASTM D1535", "McCamy 1987"])
114 ... # doctest: +ELLIPSIS
115 (<Figure size ... with 1 Axes>, <...Axes...>)
117 .. image:: ../_static/Plotting_Plot_Multi_Munsell_Value_Functions.png
118 :align: center
119 :alt: plot_multi_munsell_value_functions
120 """
122 functions_filtered = filter_passthrough(MUNSELL_VALUE_METHODS, functions)
124 settings: Dict[str, Any] = {
125 "bounding_box": (0, 100, 0, 10),
126 "legend": True,
127 "title": f"{', '.join(functions_filtered)} - Munsell Functions",
128 "x_label": "Luminance Y",
129 "y_label": "Munsell Value V",
130 }
131 settings.update(kwargs)
133 return plot_multi_functions(
134 functions_filtered, samples=np.linspace(0, 100, 1000), **settings
135 )