Plotting with numpy masked arrays

Viewed 2636

Why does matplotlib/numpy not plot unmasked points with a line? This issue is only with plotting as a line. Scatter or point plotting works okay.

import numpy as np
import matplotlib.pyplot as plt

x = np.ma.array([0, 1, 2, 3, 4])

x[[1, 3]] = np.ma.masked # issue is only when its set this way; but this is recommended in the docs
# x = np.ma.masked_where(x < 3) # this works fine for all plotting

plt.plot(x) # this shows nothing, but the axes are set correctly
plt.show()

plt.plot(x, "o") # this shows the points
plt.show()
0 Answers
Related