Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 818
user1676605 Avatar asked Aug 24 '13 22:08

user1676605


People also ask

How do you plot a graph using Numpy in Python?

For plotting graphs in Python, we will use the Matplotlib library. Matplotlib is used along with NumPy data to plot any type of graph. From matplotlib we use the specific function i.e. pyplot(), which is used to plot two-dimensional data.

What does plot () do in Python?

The plot() function is used to draw points (markers) in a diagram. By default, the plot() function draws a line from point to point. The function takes parameters for specifying points in the diagram.


1 Answers

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.

like image 178
nneonneo Avatar answered Sep 21 '22 21:09

nneonneo