Skip to content

Change in handling of scatter c= argument with shape (1, 4) #17431

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

Closed
mwaskom opened this issue May 16, 2020 · 2 comments
Closed

Change in handling of scatter c= argument with shape (1, 4) #17431

mwaskom opened this issue May 16, 2020 · 2 comments

Comments

@mwaskom
Copy link

mwaskom commented May 16, 2020

Bug report

Bug summary

In 3.2, scatter is color-mapping 4 points when the c input is 2D with shape (1, 4). This is a change from 3.1.

The docs for scatter say

Note that c should not be a single numeric RGB or RGBA sequence
because that is indistinguishable from an array of values to be
colormapped. If you want to specify the same RGB or RGBA value for
all points, use a 2-D array with a single row. Otherwise, value-
matching will have precedence in case of a size matching with x
and y.

However, this is no longer true.

I suspect #17245 may be related (only based on milestone and description, I haven't debugged the code).

Code for reproduction

import matplotlib.pyplot as plt

x = y = 1, 2, 3, 4
c = [(.2, .5, .8, 1)]

f, ax = plt.subplots()
ax.scatter(x, y, c=c, s=100)  # Increase s for visibility

Actual outcome

On 3.2.1

image

Expected outcome

On 3.1.2:

image

Matplotlib version

  • Operating system: macos
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): pylab inline
  • Python version: na
  • Jupyter version (if applicable): na
  • Other libraries: na
@mwaskom
Copy link
Author

mwaskom commented May 16, 2020

Also I just noticed that the section for the docs that I quoted say "value-matching", which I think maybe is meant to be "value-mapping"? I'm not sure what value-matching means here.

@mwaskom
Copy link
Author

mwaskom commented May 16, 2020

Oops, sorry, duplicate of #17423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants