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 Aug 12, 2023
2 parents 117d310 + a8625b5 commit 2263e01
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 55 deletions.
4 changes: 2 additions & 2 deletions colour/plotting/characterisation.py
Expand Up @@ -193,7 +193,7 @@ def plot_multi_colour_checkers(
"compare_swatches": "Stacked" if compare_swatches else None,
}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_multi_colour_swatches(colour_swatches, **settings)

Expand All @@ -215,7 +215,7 @@ def plot_multi_colour_checkers(
settings.update(
{
"axes": axes,
"standalone": True,
"show": True,
"title": ", ".join(colour_checker_names),
}
)
Expand Down
10 changes: 5 additions & 5 deletions colour/plotting/colorimetry.py
Expand Up @@ -786,7 +786,7 @@ def plot_visible_spectrum(

settings: Dict[str, Any] = {"bounding_box": bounding_box, "y_label": None}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

_figure, axes = plot_single_sd(
sd_ones(cmfs.shape),
Expand All @@ -800,7 +800,7 @@ def plot_visible_spectrum(

settings = {
"axes": axes,
"standalone": True,
"show": True,
"title": f"The Visible Spectrum - {cmfs.display_name}",
"x_label": "Wavelength $\\lambda$ (nm)",
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ def plot_blackbody_spectral_radiance(
"y_label": "W / (sr m$^2$) / m",
}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_single_sd(sd, cmfs.name, **settings)

Expand All @@ -1087,11 +1087,11 @@ def plot_blackbody_spectral_radiance(
"y_ticker": False,
}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

figure, axes = plot_single_colour_swatch(RGB, **settings)

settings = {"axes": axes, "standalone": True}
settings = {"axes": axes, "show": True}
settings.update(kwargs)

return render(**settings)
Expand Down
25 changes: 17 additions & 8 deletions colour/plotting/common.py
Expand Up @@ -76,6 +76,7 @@
runtime_warning,
validate_method,
)
from colour.utilities.deprecation import handle_arguments_deprecation

__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
Expand Down Expand Up @@ -564,7 +565,7 @@ class KwargsRender(TypedDict):
Axes to apply the render elements onto.
filename
Figure will be saved using given ``filename`` argument.
standalone
show
Whether to show the figure and call :func:`matplotlib.pyplot.show`
definition.
aspect
Expand Down Expand Up @@ -600,7 +601,7 @@ class KwargsRender(TypedDict):
figure: plt.Figure
axes: plt.Axes
filename: str
standalone: bool
show: bool
aspect: Literal["auto", "equal"] | float
axes_visible: bool
bounding_box: ArrayLike
Expand Down Expand Up @@ -636,10 +637,17 @@ def render(**kwargs: KwargsRender | Any) -> Tuple[plt.Figure, plt.Axes]:
figure = cast(plt.Figure, kwargs.get("figure", plt.gcf()))
axes = cast(plt.Axes, kwargs.get("axes", plt.gca()))

handle_arguments_deprecation(
{
"ArgumentRenamed": [["standalone", "show"]],
},
**kwargs,
)

settings = Structure(
**{
"filename": None,
"standalone": True,
"show": True,
"aspect": None,
"axes_visible": True,
"bounding_box": None,
Expand Down Expand Up @@ -683,11 +691,12 @@ def render(**kwargs: KwargsRender | Any) -> Tuple[plt.Figure, plt.Axes]:

if settings.transparent_background:
figure.patch.set_alpha(0)
if settings.standalone:
if settings.filename is not None:
figure.savefig(settings.filename)
else:
plt.show()

if settings.filename is not None:
figure.savefig(settings.filename)

if settings.show:
plt.show()

return figure, axes

Expand Down
4 changes: 2 additions & 2 deletions colour/plotting/corresponding.py
Expand Up @@ -108,7 +108,7 @@ def plot_corresponding_chromaticities_prediction(

settings = {"axes": axes, "title": title}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_chromaticity_diagram_CIE1976UCS(**settings)

Expand Down Expand Up @@ -164,7 +164,7 @@ def plot_corresponding_chromaticities_prediction(

settings.update(
{
"standalone": True,
"show": True,
"bounding_box": (-0.1, 0.7, -0.1, 0.7),
}
)
Expand Down
10 changes: 5 additions & 5 deletions colour/plotting/diagrams.py
Expand Up @@ -577,15 +577,15 @@ def plot_chromaticity_diagram(
if show_diagram_colours:
settings = {"axes": axes, "method": method, "diagram_colours": "RGB"}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False
settings["cmfs"] = cmfs

plot_chromaticity_diagram_colours(**settings)

if show_spectral_locus:
settings = {"axes": axes, "method": method}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False
settings["cmfs"] = cmfs

plot_spectral_locus(**settings)
Expand All @@ -605,7 +605,7 @@ def plot_chromaticity_diagram(
settings.update(
{
"axes": axes,
"standalone": True,
"show": True,
"bounding_box": (0, 1, 0, 1),
"title": title,
"x_label": x_label,
Expand Down Expand Up @@ -913,7 +913,7 @@ def plot_sds_in_chromaticity_diagram(
settings.update(
{
"axes": axes,
"standalone": False,
"show": False,
"method": method,
"cmfs": cmfs,
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def XYZ_to_ij(XYZ: NDArrayFloat) -> NDArrayFloat:

axes.annotate(sd.name, xy=ij, **annotate_settings)

settings.update({"standalone": True, "bounding_box": bounding_box})
settings.update({"show": True, "bounding_box": bounding_box})
settings.update(kwargs)

return render(**settings)
Expand Down
14 changes: 7 additions & 7 deletions colour/plotting/models.py
Expand Up @@ -535,14 +535,14 @@ def plot_RGB_colourspaces_in_chromaticity_diagram(

settings = {"axes": axes, "title": title, "method": method}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

chromaticity_diagram_callable(**settings)

if show_pointer_gamut:
settings = {"axes": axes, "method": method}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_pointer_gamut(**settings)

Expand Down Expand Up @@ -653,7 +653,7 @@ def xy_to_ij(xy: NDArrayFloat) -> NDArrayFloat:

settings.update(
{
"standalone": True,
"show": True,
"legend": True,
"bounding_box": bounding_box,
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ def plot_RGB_chromaticities_in_chromaticity_diagram(
scatter_settings.update(scatter_kwargs)

settings = dict(kwargs)
settings.update({"axes": axes, "standalone": False})
settings.update({"axes": axes, "show": False})

colourspace = cast(
RGB_Colourspace,
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def plot_RGB_chromaticities_in_chromaticity_diagram(

axes.scatter(ij[..., 0], ij[..., 1], **scatter_settings)

settings.update({"standalone": True})
settings.update({"show": True})
settings.update(kwargs)

return render(**settings)
Expand Down Expand Up @@ -1453,7 +1453,7 @@ def plot_ellipses_MacAdam1942_in_chromaticity_diagram(
_figure, axes = artist(**settings)

settings = dict(kwargs)
settings.update({"axes": axes, "standalone": False})
settings.update({"axes": axes, "show": False})

ellipses_coefficients = ellipses_MacAdam1942(method=method)

Expand Down Expand Up @@ -1512,7 +1512,7 @@ def plot_ellipses_MacAdam1942_in_chromaticity_diagram(
)
axes.add_artist(ellipse)

settings.update({"standalone": True})
settings.update({"show": True})
settings.update(kwargs)

return render(**settings)
Expand Down
6 changes: 3 additions & 3 deletions colour/plotting/phenomena.py
Expand Up @@ -195,7 +195,7 @@ def plot_the_blue_sky(
"y_label": "W / m-2 / nm-1",
}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_single_sd(sd, cmfs, **settings)

Expand All @@ -219,15 +219,15 @@ def plot_the_blue_sky(
"y_ticker": False,
}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

blue_sky_color = XYZ_to_plotting_colourspace(sd_to_XYZ(sd))

figure, axes = plot_single_colour_swatch(
ColourSwatch(normalise_maximum(blue_sky_color)), **settings
)

settings = {"axes": axes, "standalone": True}
settings = {"axes": axes, "show": True}
settings.update(kwargs)

return render(**settings)
4 changes: 2 additions & 2 deletions colour/plotting/quality.py
Expand Up @@ -335,7 +335,7 @@ def plot_multi_sds_colour_rendering_indexes_bars(
sds_converted = sds_and_msds_to_sds(sds)

settings: Dict[str, Any] = dict(kwargs)
settings.update({"standalone": False})
settings.update({"show": False})

specifications = cast(
List[ColourRendering_Specification_CRI],
Expand Down Expand Up @@ -474,7 +474,7 @@ def plot_multi_sds_colour_quality_scales_bars(
sds_converted = sds_and_msds_to_sds(sds)

settings: Dict[str, Any] = dict(kwargs)
settings.update({"standalone": False})
settings.update({"show": False})

specifications = cast(
List[ColourRendering_Specification_CQS],
Expand Down
12 changes: 6 additions & 6 deletions colour/plotting/section.py
Expand Up @@ -596,7 +596,7 @@ def plot_visible_spectrum_section(
if show_section_colours:
settings = {"axes": axes}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_hull_section_colours(
hull, model, axis, origin, normalise, **settings
Expand All @@ -605,7 +605,7 @@ def plot_visible_spectrum_section(
if show_section_contour:
settings = {"axes": axes}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_hull_section_contour(
hull, model, axis, origin, normalise, **settings
Expand All @@ -628,7 +628,7 @@ def plot_visible_spectrum_section(
settings.update(
{
"axes": axes,
"standalone": True,
"show": True,
"title": title,
"x_label": x_label,
"y_label": y_label,
Expand Down Expand Up @@ -749,7 +749,7 @@ def plot_RGB_colourspace_section(
if show_section_colours:
settings = {"axes": axes}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_hull_section_colours(
hull, model, axis, origin, normalise, **settings
Expand All @@ -758,7 +758,7 @@ def plot_RGB_colourspace_section(
if show_section_contour:
settings = {"axes": axes}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

plot_hull_section_contour(
hull, model, axis, origin, normalise, **settings
Expand All @@ -780,7 +780,7 @@ def plot_RGB_colourspace_section(
settings.update(
{
"axes": axes,
"standalone": True,
"show": True,
"title": title,
"x_label": x_label,
"y_label": y_label,
Expand Down
4 changes: 2 additions & 2 deletions colour/plotting/temperature.py
Expand Up @@ -509,7 +509,7 @@ def plot_planckian_locus_in_chromaticity_diagram(

settings = {"axes": axes, "method": method}
settings.update(kwargs)
settings["standalone"] = False
settings["show"] = False

chromaticity_diagram_callable(**settings)

Expand Down Expand Up @@ -618,7 +618,7 @@ def xy_to_ij(xy: NDArrayFloat) -> NDArrayFloat:
settings.update(
{
"axes": axes,
"standalone": True,
"show": True,
"bounding_box": bounding_box,
"title": title,
}
Expand Down

0 comments on commit 2263e01

Please sign in to comment.