Coverage for plotting/notation.py: 30%

1"""

2 Colour Notation Systems Plotting

3================================

4

5 Define the colour notation systems plotting objects.

6

7- :func:`colour.plotting.plot_single_munsell_value_function`

8- :func:`colour.plotting.plot_multi_munsell_value_functions`

9"""

10

11 from __future__ import annotations

12

13 import typing

14

15 import numpy as np

16

17 if typing.TYPE_CHECKING:

18 from matplotlib.axes import Axes

19 from matplotlib.figure import Figure

20

21 if typing.TYPE_CHECKING:

22 from colour.hints import Any, Callable, Dict, Sequence, Tuple

23

24 from colour.notation import MUNSELL_VALUE_METHODS

25 from colour.plotting import filter_passthrough, override_style, plot_multi_functions

26

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"

33

34 __all__ = [

35 "plot_single_munsell_value_function",

36 "plot_multi_munsell_value_functions",

37]

38

39

40@override_style()

41 def plot_single_munsell_value_function(

42 function: Callable | str, **kwargs: Any

43) -> Tuple[Figure, Axes]:

44 """

45 Plot the specified *Munsell* value function.

46

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.

53

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.

61

62 Returns

63 -------

64 :class:`tuple`

65 Current figure and axes.

66

67 Examples

68 --------

69 >>> plot_single_munsell_value_function("ASTM D1535") # doctest: +ELLIPSIS

70 (<Figure size ... with 1 Axes>, <...Axes...>)

71

72 .. image:: ../_static/Plotting_Plot_Single_Munsell_Value_Function.png

73 :align: center

74 :alt: plot_single_munsell_value_function

75 """

76

77 settings: Dict[str, Any] = {"title": f"{function} - Munsell Value Function"}

78 settings.update(kwargs)

79

80 return plot_multi_munsell_value_functions((function,), **settings)

81

82

83@override_style()

84 def 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.

90

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.

97

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.

105

106 Returns

107 -------

108 :class:`tuple`

109 Current figure and axes.

110

111 Examples

112 --------

113 >>> plot_multi_munsell_value_functions(["ASTM D1535", "McCamy 1987"])

114 ... # doctest: +ELLIPSIS

115 (<Figure size ... with 1 Axes>, <...Axes...>)

116

117 .. image:: ../_static/Plotting_Plot_Multi_Munsell_Value_Functions.png

118 :align: center

119 :alt: plot_multi_munsell_value_functions

120 """

121

122 functions_filtered = filter_passthrough(MUNSELL_VALUE_METHODS, functions)

123

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)

132

133 return plot_multi_functions(

134 functions_filtered, samples=np.linspace(0, 100, 1000), **settings

135 )