yellowbrick icon indicating copy to clipboard operation
yellowbrick copied to clipboard

Matplotlib>= 2.0 has default property cycle in Hex, while color_palette() and get_color_cycle() return RGB

Open nickpowersys opened this issue 5 years ago • 2 comments

Example

The Anscombe example subplots in anscombe.py are correctly generated but there is a warning from matplotlib (3.0.3). For context, the argument to the c parameter is a 3-tuple.

'c' argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points.

The call in anscombe.py is

ax.scatter(x, y, c=color)

@DistrictDataLabs/team-oz-maintainers

nickpowersys avatar Mar 31 '19 23:03 nickpowersys

@nickpowersys thanks for pointing this out. We just came back from a haitus and still going through our backlog of issues and PRs. We will respond more fully asap. We definitely need to address this as We have several issues about color that are open. #677

lwgray avatar Apr 01 '19 00:04 lwgray

This is related to the warning occurring in the examples.ipynb notebook, with any user's experience trying out Anscombe's Quartet, as well as any scatter plots using an RGB cycle from get_color_cycle().

Within anscombe.py, the get_color_cycle() function returns the yellowbrick palette as an RGB cycle.

This is because within get_color_cycle(), the color_palette() function takes the yellowbrick palette, which is in Hex, and converts it to RGB.

The warning would go away if the palette stayed as Hex instead.

Also, starting with matplotlib 2.0, matplotlib's default property cycle (prop_cycle) was expressed in Hex. https://matplotlib.org/users/dflt_style_changes.html#colors-in-default-property-cycle

For consistency with the current matplotlib and to avoid other warnings associated with RGB, would it make sense to test having color_palette() return Hex values instead of converting to RGB?

This is the relevant section of color_palette():

# Always return in RGB tuple format
    try:
        palette = map(mpl.colors.colorConverter.to_rgb, palette)
        palette = ColorPalette(palette)
    except ValueError:
        raise YellowbrickValueError(
            "Could not generate a palette for %s" % str(palette)
        )

nickpowersys avatar Jul 17 '19 17:07 nickpowersys