-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
API: consistencyDifficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesmentored: hackathon
Milestone
Description
I want to plot some data with a given color code. For example:
x = np.array([0, 1, 2, 3])
b = np.array([1, 0, 2, 3])
colors = np.array(['g', 'r', 'b', 'y'])
plt.scatter(x, b**2, color=colors)
Great, all the points appear, each one with its color. Now, some data is missing:
plt.figure()
plt.scatter(x, np.log10(b), color=colors)
Here comes the problem: the x=1 data is missing (log(0)=NaN), but the colors are skipping this point and the x=2 point is red, not blue. The solution can be:
y = np.log10(b)
mask = np.isfinite(y)
plt.scatter(x[mask], y[mask], color=colors[mask])
but I feel it so uncomfortable to do this... Any other way? Is this a kind of bug?
Thanks,
Christophe
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
API: consistencyDifficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesmentored: hackathon