colour-science / colour

Colour Science for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
2.03k stars 257 forks source link

[BUG]: Exception raised in `colour.plotting.plot_RGB_scatter` definition. #1218

Closed GuillemRamisa closed 8 months ago

GuillemRamisa commented 8 months ago

Description

When executing the colour.plotting.plot_RGB_scatter example code on the colour.science docs: colour.plotting.plot_RGB_scatter

RGB = np.random.random((128, 128, 3))
colour.plotting.plot_RGB_scatter(RGB, "ITU-R BT.709")

An error message prompts, resulting on exit.

This issue can be fixed by replacing in ".../mpl_toolkits/mplot3d/axes3d.py" line 2377 from:

        if kwargs.get('color', None):

to:

        if kwargs.get('color', None).all():

or:

        if kwargs.get('color', None).any():

Code for Reproduction

RGB = np.random.random((128, 128, 3))
colour.plotting.plot_RGB_scatter(RGB, "ITU-R BT.709")

Exception Message

line 2377, in scatter
    if kwargs.get('color', None):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Environment Information

===============================================================================
*                                                                             *
*   Interpreter :                                                             *
*       python : 3.10.11 (main, May 17 2023, 00:03:58) [GCC 12.2.0]           *
*                                                                             *
*   colour-science.org :                                                      *
*       colour : 0.4.3                                                        *
*                                                                             *
*   Runtime :                                                                 *
*       imageio : 2.31.6                                                      *
*       matplotlib : 3.8.0                                                    *
*       networkx : 3.2.1                                                      *
*       numpy : 1.26.1                                                        *
*       scipy : 1.11.3                                                        *
*                                                                             *
===============================================================================
KelSolaar commented 8 months ago

Thanks @GuillemRamisa,

I will take a look, this might be related to changes in MPL.

KelSolaar commented 8 months ago

I think I fixed it already in develop when Matplotlib 3.8.0 was released as they implemented a bunch of breaking changes.

KelSolaar commented 8 months ago

Oh and last one, because of very poor 3D plotting capabilities, we are working on a new repository that will eventually replace our current 3D definitions: https://github.com/colour-science/colour-visuals, https://colour-visuals.readthedocs.io/

GuillemRamisa commented 8 months ago

Thanks @KelSolaar, that's what I thought, a while ago I tested it with an older version of MPL and it worked. Thanks for the link, I wasn't aware!