# Python | Y-axis Scale Limit

Y-axis Scale Limit in Python. Here, we are going to learn about the y-axis scale limit and its Python implementation, how to change the y-axis scale limit?
Submitted by Anuj Singh, on July 19, 2020

In some cases, we need to visualize our data within some defined range rather than the whole data. For this, we generally set the y-axis scale within a limit and this ultimately helps us to visualize better. Sometimes, it acts as zooming and a very helpful technique in data visualization. Therefore, Matplotlib has a defined function for this operation matplotlib.pyplot.ylim().

Following is an example showing a different y-axis Limit in plots using matplotlib.pyplot.

Syntax:

```matplotlib.pyplot.ylim(lower_limit, upper_limit )
plt.show()
```  ## Python code for y-axis scale limit

```import numpy as np
import matplotlib.pyplot as plt

x = np.arange(500)
y1 = np.arange(500)
for i in range(500):
y1[i] = 2*x[i] + np.random.randint(0,56)

plt.figure()
plt.plot(x,y1)
plt.xlabel('Number Line')
plt.ylabel('Function')
plt.title('Whole Data')

plt.figure()
plt.plot(x,y1)
plt.ylim(-1000,2000)
plt.xlabel('Number Line')
plt.ylabel('Function')
plt.title('Limit for Y axis is Set')
```

Output:

```Output is as figure
```