Forklift17
Forklift17

Reputation: 2477

matplotlib turn an array into a parametric plot

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

Answers (1)

vipersassassin
vipersassassin

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

Related Questions