colour-science / colour

Colour Science for Python

Home Page:https://www.colour-science.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

GuillemRamisa opened this issue · comments

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                                                        *
*                                                                             *
===============================================================================

Thanks @GuillemRamisa,

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

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

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/

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!