Skip to content

scatter not showing valid x/y points with invalid color #4354

Closed
@megies

Description

@megies

scatter plots are removing points with valid x/y coordinates but invalid color value. As colormaps have a special setting for what color should be used in case of invalid data points (used e.g. in imshow array plots) maybe these points should indeed be plotted and plotted with the specified "bad value" color.

Consider this example:

import matplotlib.pyplot as plt
from matplotlib.cm import spring
import numpy as np

spring.set_bad("k", 1)

colors = np.array([1, 3, 9, np.nan])
x = [0, 1, 2, 3]

plt.figure()
plt.imshow(colors.reshape((2, 2)), interpolation="nearest", cmap=spring)

plt.figure()
plt.scatter(x, x, s=1e4, c=colors, cmap=spring)
plt.show()

The right-hand side scatter plot is not showing the x=3, y=3, color=np.nan data point:

figure_1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions