# Only size-1 arrays can be converted to Python scalars

# problem

```
only size-1 arrays can be converted to Python scalars
```

This comes out and the graph doesn't work well! !!

This is the source code of the problem

```
import matplotlib.pyplot as plt
import math
import np
x = np.linspace(0,1, 10000);
def y(a):
return math.exp(a)
plt.figure(0)
plt.plot(x, y(x))
plt.show()
```

# Cause

### math functions can't handle matrices

Solved by using exp with numpy function

```
plt.plot(x, y(x))
```

Be careful because I'm throwing a line in this part

Therefore

```
def y(a):
return np.exp(a)
```

If so, heal

# Code after resolution

```
import matplotlib.pyplot as plt
import math
import numpy
x = np.linspace(0,1, 10000);
def y(a):
return np.exp(a)
plt.figure(0)
plt.plot(x, y(x))
plt.show()
```

reference:
https://blog.csdn.net/u013634684/article/details/49305655?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase