Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nickpowersys opened this issue Mar 31, 2019 · 2 comments
Labels
type: technical debt work to optimize or generalize code

Comments

@nickpowersys
Copy link
Contributor

nickpowersys commented Mar 31, 2019

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

@lwgray
Copy link
Contributor

lwgray commented Apr 1, 2019

@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

@nickpowersys
Copy link
Contributor Author

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 nickpowersys changed the title Matplotlib warning triggered by scatter plot with x, y arrays of size>1 and 3-tuple for color Matplotlib>= 2.0 has defaulty property cycle in Hex, while color_palette() and get_color_cycle() return RGB Jul 17, 2019
@nickpowersys nickpowersys changed the title Matplotlib>= 2.0 has defaulty property cycle in Hex, while color_palette() and get_color_cycle() return RGB Matplotlib>= 2.0 has default property cycle in Hex, while color_palette() and get_color_cycle() return RGB Jul 17, 2019
@bbengfort bbengfort added the type: technical debt work to optimize or generalize code label Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: technical debt work to optimize or generalize code
Projects
None yet
Development

No branches or pull requests

3 participants