# Learn Coordinate Geometry With Intuitive Way - Part 1

## Series: Python for kids

In our endavor to make learning fun and free of memorization, we have been using Python to allow children to experiment and analyze data to form their own opinion and discover facts. This way, children engage is learning process with more intensity and the they show higher retention rate vis a vis conventional learning.

This makes them think and try different things before they get it right. The focus shifts from being always ‘right’ to get it right after several failed attempts.

### In this part of the series

Children create simple shapes using markers, move marker left, right , top and bottom. They learn coordinates geometry where the position of points on the plane.

In this blog we are using Matplotlibn library. Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy.

### Import library

In [1]:
import matplotlib.pyplot as plt


## Plot a point at (2, -5)

In [2]:
x = 2
y = -5

plt.plot(x, y, marker = 'o')
plt.show()


### Increase size of point

In [3]:
plt.plot(x, y, marker = 'o', markersize = 15)
plt.show()


### Add annotation to the point and set the limit of x axis an y axis

matplotlib.pyplot.xlim(*args, **kwargs): Get or set the x limits of the current axes.

matplotlib.pyplot.ylim(*args, **kwargs): Get or set the y limits of the current axes.

We are getting min and max of x and y value, after that setting the limits of X-axis between min and max value. Same thing we are doing to set Y-axis limit.

In [4]:
plt.plot(x, y, marker = 'o', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.2, y), xycoords='data')

xyMin = min(0, x, 0, y) - 1
xyMax = max(0, x, 0, y) + 1

plt.xlim(xyMin, xyMax)
plt.ylim(xyMin, xyMax)

plt.show()


## Plot two points at (7, 0) and (1, -2) with annotation

In [5]:
x1 = 7
y1 = 0

x2 = 1
y2 = -2

In [6]:
plt.plot(x1, y1, marker = 'o', markersize = 15)
plt.plot(x2, y2, marker = 'o', markersize = 15)

xyMin = min(x1, y1, x2, y2) - 1
xyMax = max(x1, y1, x2, y2) + 1

plt.xlim(xyMin, xyMax)
plt.ylim(xyMin, xyMax)

plt.show()


### Add anotations

In [7]:
plt.plot(x1, y1, marker = 'o', markersize = 15)
plt.plot(x2, y2, marker = 'o', markersize = 15)

plt.gca().annotate(f'({x1}, {y1})', xy=(x1 + 0.2, y1), xycoords='data')
plt.gca().annotate(f'({x2}, {y2})', xy=(x2 + 0.2, y2), xycoords='data')

xyMin = min(x1, y1, x2, y2) - 1
xyMax = max(x1, y1, x2, y2) + 1

plt.xlim(xyMin, xyMax)
plt.ylim(xyMin, xyMax)

plt.show()


## Plot three points at (5, 0) , (-5, 2) and (1, -5) with annotation and make a triangle

### Declare points

In [8]:
x1 = 5
y1 = 0

x2 = -5
y2 = 2

x3 = 1
y3 = -5


### Plot triangle

In [9]:
plt.plot(x1, y1, marker = 'o', markersize = 15)
plt.plot(x2, y2, marker = 'o', markersize = 15)
plt.plot(x3, y3, marker = 'o', markersize = 15)

plt.plot((x1, x2, x3, x1), (y1, y2, y3, y1), color = 'red')

plt.gca().annotate(f'({x1}, {y1})', xy=(x1 + 0.2, y1), xycoords='data')
plt.gca().annotate(f'({x2}, {y2})', xy=(x2 + 0.2, y2), xycoords='data')
plt.gca().annotate(f'({x3}, {y3})', xy=(x3 + 0.2, y3), xycoords='data')

xyMin = min(x1, y1, x2, y2, x3, y3) - 1
xyMax = max(x1, y1, x2, y2, x3, y3) + 1

plt.xlim(xyMin, xyMax)
plt.ylim(xyMin, xyMax)

plt.show()


## Walk like below:

Start from (2, -4) and plot the moves as follows:

1. Go left by 4 and up by 5
2. Go left by 3 and up by 6
3. Go right by 10 and down by 4
4. Go left by 10 and down by 7
5. Go down by 5

### Plot staring paint (2, -4)

In [10]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 10)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.2, y), xycoords='data')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()


### Go left by 4 and up by 5 from starting point

In [11]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5, y), xycoords='data')

#declare a starting point, which is x and y
xStart = x
yStart = y

#move left by 4, so x will be xstart + (-4)
#move up by 5, so y will be ystart + 5
x = xStart + -4
y = yStart + 5

plt.plot(x, y, marker = 'o', color = 'blue', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()


### Go left by 3 and up by 6

In [12]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5, y), xycoords='data')

xStart = x
yStart = y
x = xStart + -4
y = yStart + 5

plt.plot(x, y, marker = 'o', color = 'blue', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -3
y = yStart + 6

plt.plot(x, y, marker = 'o', color = 'yellow', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()


### Go right by 10 and down by 4

In [13]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5, y), xycoords='data')

xStart = x
yStart = y
x = xStart + -4
y = yStart + 5

plt.plot(x, y, marker = 'o', color = 'blue', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -3
y = yStart + 6

plt.plot(x, y, marker = 'o', color = 'yellow', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + 10
y = yStart + -4

plt.plot(x, y, marker = 'o', color = 'purple', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()


### Go left by 10 and down by 7

In [14]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5, y), xycoords='data')

xStart = x
yStart = y
x = xStart + -4
y = yStart + 5

plt.plot(x, y, marker = 'o', color = 'blue', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -3
y = yStart + 6

plt.plot(x, y, marker = 'o', color = 'yellow', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + 10
y = yStart + -4

plt.plot(x, y, marker = 'o', color = 'purple', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -10
y = yStart + -7

plt.plot(x, y, marker = 'o', color = 'green', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()


### Go down by 5

In [15]:
x = 2
y = -4

plt.plot(x, y, marker = 'o', color = 'red', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5, y), xycoords='data')

xStart = x
yStart = y
x = xStart + -4
y = yStart + 5

plt.plot(x, y, marker = 'o', color = 'blue', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -3
y = yStart + 6

plt.plot(x, y, marker = 'o', color = 'yellow', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + 10
y = yStart + -4

plt.plot(x, y, marker = 'o', color = 'purple', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + -10
y = yStart + -7

plt.plot(x, y, marker = 'o', color = 'green', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

xStart = x
yStart = y
x = xStart + 0
y = yStart + -5

plt.plot(x, y, marker = 'o', color = 'grey', markersize = 15)
plt.gca().annotate(f'({x}, {y})', xy=(x + 0.5 , y), xycoords='data')
plt.plot((xStart, x), (yStart, y), color = 'green')

plt.xlim(-15, 15)
plt.ylim(-15, 15)
plt.show()