Simple Plot in Python of a Numpy Array?

I have an array that looks like this

cplr = array([ 0.01828922,  0.01972157,  0.02342053, ...,  0.25928021,
    0.26352547,  0.26883406])

If I say

import matplotlib.pyplot as plt
plt(cplr)

TypeError: 'module' object is not callable

How do I plot the contents of a numpy array?

1 Answer

matplotlib.pyplot is a module; the function to plot is matplotlib.pyplot.plot. Thus, you should do

plt.plot(cplr)
plt.show()

A good place to learn more about this would be to read a matplotlib tutorial.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest