# Graph Plot of X and Y-Axis for given values as input in Python3

Learn the graph plot in Python using matplotlib and pyplot.

## GRAPH PLOT in Python

GRAPH PLOT:

1. The user first inputs the X-Axis values.
2. Then, he/she inputs the Y-Axis values.
3. The program will execute a graph plotting the actual coordinates according to functions.
• First Function: y=x              –> (Green Triangles)
• Second Function: y=x+20  –> (Blue Squares)
• Third Function: y=x+30     –> (Red Dots)

The library that is the key thing for this program is: matplotlib.pyplot

Read more here: matplotlib.pyplot

The following is the code snippet and the graph in output.

PROGRAM:

```import matplotlib.pyplot as plt
print("Input X-Axis values:")
x=list(map(int,input().split(","))) #input x axis values
x.sort()
y1=[0 for i in range(len(x))] #initialize list y1
y2=[0 for i in range(len(x))] #initialize list y2
y3=[0 for i in range(len(x))] #initialize list y3
for i in range(len(x)):
y1[i]=x[i]
for i in range(len(x)):
y2[i]=x[i]+20
for i in range(len(x)):
y3[i]=x[i]+30
maxx=max(x)
maxy=max(y3)
plt.plot(x,y1,'g^') #'g' stands for green and '^' stands for triangle
plt.plot(x,y2,'bs') #'b' stands for blue and 's' stands for square
plt.plot(x,y3,'ro') #'r' stands for red and 'o' stands for dot
plt.axis([0,maxx+1,0,maxy+1])
plt.show()```

OUTPUT:

```Input X-Axis values:
2,5,10,15,20,25,30,35,40,45,50,55,60,65,70```

Output

The Y-axis can be given input too. For example:

PROGRAM 2:

```import matplotlib.pyplot as plt
print("Input X-Axis values:")
x=list(map(int,input().split(",")))
x.sort()
print("Input Y-Axis values:")
y=list(map(int,input().split(",")))
plt.plot(x,y,'r^')  #plotting in blue triangle
maxx=max(x)
maxy=max(y)
plt.axis([0,maxx+1,0,maxy+1])
plt.show()```

OUTPUT:

```Input X-Axis values:
1,2,3,4,5,6,7,8,9
Input Y-Axis values:
7,8,9,6,4,5,2,1,6
```

output