Reputation: 2477
Suppose I have the following script:
import numpy as np
import matplotlib.pyplot as plt
A = np.array([[1,1,1,0],[0,0,1,0],[0,1,0,0],[0,0,0,0]])
How can I plot just the values of A that are equal to 1, leaving the 0's blank? Basically I'm looking to plot just those points, and not as a pcolormesh or something similar.
Upvotes: 1
Views: 409
Reputation: 178
If you change the values to non-integer values they will not appear in your array.
x(x == -1) = NaN;
plot(x)
Upvotes: 1