Skip to content

Plotting three points using scatter results in wrong color - 1.4.3 #5377

Closed
@liujimj

Description

@liujimj

I'm running this on Windows 10 / Anaconda Python 3.4.3 / jupyter iPython 4

Here's some repro code:

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(1)
ax = plt.axes([0., 0., 1., 1.])

points = np.random.rand(2,2) # plot 2 points, totally fine
ax.scatter(points[0], points[1], c=[1, 0, 0],  s=200)
points = np.random.rand(2,3) # plot 3 points, hopelessly broken
ax.scatter(points[0], points[1], c=[0, 1, 0], s=200)
points = np.random.rand(2,3) # plot 3 points with string color, totally ok
ax.scatter(points[0], points[1], c='g', s=200)
points = np.random.rand(2,4) # plot 4 points, totally fine
ax.scatter(points[0], points[1], c=[0, 0, 1], s=200)
plt.show()

Here's what I get:

download 1

As you can see, plotting 2, 4, or any other number of points using ax.scatter is fine, but graphing 3 points while using RGB color array results in two points as black, and one point as white, instead of using the specified color.

Here's an example on a real dataset. As you can see, it also messes with the legend color. It's hard to diagnose the issue because it's completely non-obvious that the number of points plotted is what triggers the bug.
download 2

I was pulling my hair out for awhile until I realized that the problem only manifested itself on series that had 3 members.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions