Numpy is a python package that allows you to create a numpy array. After that, you can manipulate these arrays using complex mathematical computation. It just allows you to do computational work fast. Sometimes you have to plot the numpy array using the plot() function and suddenly you encounter the error AttributeError ‘numpy.ndarray’ object has no attribute ‘plot’. Then how you can solve it quickly? In this entire post, you will learn to solve this error.

## Why AttributeError ‘numpy.ndarray’ object has no attribute ‘plot’ Error Comes?

You are getting this attributeError due to many reasons. But the most obvious reason is that you may be using the plot() function on a different objects. If you use the plot() function on the numpy array you have created then you will get the ‘numpy.ndarray’ object has no attribute ‘plot’ error.

You will get this error when you run the below lines of code.

```
import numpy as np
numpy_array = np.array([10,20,30,40,50])
numpy_array.plot()
```

**Output**

## Solution of ‘numpy.ndarray’ object has no attribute ‘plot’ Error

The solution to this plot error is very easy and simple. You don’t have to use the plot() function on the numpy array. Instead, you have apply the plot() function on the dataframe columns.

To do so first convert the numpy array to dataframe and then apply the plot() function on the dataframe. You will use the pandas.DataFrame() to convert the numpy array to dataframe.

Run the below lines of code to plot your numpy array.

```
import numpy as np
import pandas as pd
numpy_array = np.array([10,20,30,40,50])
df = pd.DataFrame(numpy_array)
df.plot()
```

Now you will not get the error and output the line plot.

## Conclusion

In this tutorial, you have learned how to plot the numpy array as a line chart. Firstly you will convert the numpy array to pandas dataframe. Lastly, call the plot() function on the dataframe. The above method will solve the error easily if you are getting plot() attribute error.

I hope you have liked this tutorial. If you are getting this error and still not able to solve it then you can contact us for help.

#### Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.