Draw Step by Step Badminton Court Using Python Matplotlib Module

Nutan
11 min readDec 10, 2021

In this blog, we will draw badminton court using Python’s Matplotlib module.

Created by Nutan

We are taking dimension data from below source:

Source

Import Matplotlib Module

import matplotlib.pyplot as plt

Draw Canvas area

​plt.figure(figsize = (18, 7))plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw clearance area

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw Doubles Sideline

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline area
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw Singles Sidelines

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw Net in the middle

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
#net points
#take the middle of doubles sideline bottom points
x = (2 + 11)/2
plt.plot(x, 2.5, marker = 'o')
plt.plot(x, 10.5, marker = 'o')
plt.plot([x, x], [2.5, 10.5])
plt.gca().annotate('Net', xy=(x, 6.5), xycoords='data', fontsize=12, rotation=270)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw Short Service Line

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
#net points
#take the middle of doubles sideline bottom points
x = (2 + 11)/2
#print(x)
plt.plot(x, 2.5, marker = 'o')
plt.plot(x, 10.5, marker = 'o')
plt.plot([x, x], [2.5, 10.5])
plt.gca().annotate('Net', xy=(x, 6.5), xycoords='data', fontsize=12, rotation=270)
#left short service line
# point will start from single sideline to net. Then divide into 3 parts.
x1 = (x - 2.5)/3
print(x1)
x2 = 6.5 - x1
plt.plot(x2, 2.5, marker = 'o', color = 'red')
plt.plot(x2, 10.5, marker = 'o', color = 'red')
plt.plot([x2, x2], [2.5, 10.5])
#right short service line
x3 = 6.5 + x1
plt.plot(x3, 2.5, marker = 'o', color = 'red')
plt.plot(x3, 10.5, marker = 'o', color = 'red')
plt.plot([x3, x3], [2.5, 10.5])
plt.gca().annotate('Short Service Line', xy=(x3 - 0.3, 5), xycoords='data', fontsize=12, rotation=270)plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Write distance between short service line and net

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
#net points
#take the middle of doubles sideline bottom points
x = (2 + 11)/2
#print(x)
plt.plot(x, 2.5, marker = 'o')
plt.plot(x, 10.5, marker = 'o')
plt.plot([x, x], [2.5, 10.5])
plt.gca().annotate('Net', xy=(x, 6.5), xycoords='data', fontsize=12, rotation=270)
#left short service line
# point will start from single sideline to net. Then divide into 3 parts.
x1 = (x - 2.5)/3
#print(x1)
x2 = 6.5 - x1
plt.plot(x2, 2.5, marker = 'o', color = 'red')
plt.plot(x2, 10.5, marker = 'o', color = 'red')
plt.plot([x2, x2], [2.5, 10.5])
#right short service line
x3 = 6.5 + x1
plt.plot(x3, 2.5, marker = 'o', color = 'red')
plt.plot(x3, 10.5, marker = 'o', color = 'red')
plt.plot([x3, x3], [2.5, 10.5])
plt.gca().annotate('Short Service Line', xy=(x3 - 0.3, 5), xycoords='data', fontsize=12, rotation=270)plt.gca().annotate('<-.76 m-->', xy=(2, 3.4), xycoords='data', fontsize=8)plt.gca().annotate('<--------------- 13 inch | 3.9 m ------------->', xy=(2.5, 3.4), xycoords='data', fontsize=12)
plt.gca().annotate('<-- 6.5 inch | 1.98 m -->', xy=(x2, 3.4), xycoords='data', fontsize=10)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Draw Center Line

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
#net points
#take the middle of doubles sideline bottom points
x = (2 + 11)/2
#print(x)
plt.plot(x, 2.5, marker = 'o')
plt.plot(x, 10.5, marker = 'o')
plt.plot([x, x], [2.5, 10.5])
plt.gca().annotate('Net', xy=(x, 6.5), xycoords='data', fontsize=12, rotation=270)
#left short service line
# point will start from single sideline to net. Then divide into 3 parts.
x1 = (x - 2.5)/3
#print(x1)
x2 = 6.5 - x1
plt.plot(x2, 2.5, marker = 'o', color = 'red')
plt.plot(x2, 10.5, marker = 'o', color = 'red')
plt.plot([x2, x2], [2.5, 10.5])
#right short service line
x3 = 6.5 + x1
plt.plot(x3, 2.5, marker = 'o', color = 'red')
plt.plot(x3, 10.5, marker = 'o', color = 'red')
plt.plot([x3, x3], [2.5, 10.5])
plt.gca().annotate('Short Service Line', xy=(x3 - 0.3, 5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-.76 m-->', xy=(2, 3.4), xycoords='data', fontsize=8)
plt.gca().annotate('<--------------- 13 inch | 3.9 m ------------->', xy=(2.5, 3.4), xycoords='data', fontsize=12)
plt.gca().annotate('<-- 6.5 inch | 1.98 m -->', xy=(x2, 3.4), xycoords='data', fontsize=10)
#draw points for left center line
y1 = (2.5 + 10.5)/2
plt.plot(2, y1, marker = 'o')
plt.plot(x2, y1, marker = 'o')
plt.plot([2, x2], [y1, y1])
plt.gca().annotate('Left Service Court', xy=(3, y1 + 1.8), xycoords='data', fontsize=12)
plt.gca().annotate('Center Line', xy=(3.5, y1 + .3), xycoords='data', fontsize=12)plt.gca().annotate('Right Service Court', xy=(3, y1 - 1.8), xycoords='data', fontsize=12)plt.gca().annotate('<--8.5 inch | 2.59 m -->', xy=(2.2, y1), xycoords='data', fontsize=10, rotation=270)#draw points for right center line
plt.plot(x3, y1, marker = 'o')
plt.plot(11, y1, marker = 'o')
plt.plot([x3, 11], [y1, y1])
plt.gca().annotate('Doubles Service Line', xy=(10.6, 6.7), xycoords='data', fontsize=10, rotation=270)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.show()

Output:

Final code

plt.figure(figsize = (18, 7))#points for clearance area
plt.plot(1.5, 1.5, marker = 'o')
plt.plot(11.5, 1.5, marker = 'o')
plt.plot(11.5, 11.5, marker = 'o')
plt.plot(1.5, 11.5, marker = 'o')
plt.gca().annotate('Clearance', xy=(8, 11.8), xycoords='data', fontsize=12)
#draw line in clearance area
plt.plot([1.5, 11.5, 11.5, 1.5, 1.5], [1.5, 1.5, 11.5, 11.5, 1.5],linestyle = 'dashed')
#draw points for doubles sideline
plt.plot(2, 2.5, marker = 'o')
plt.plot(11, 2.5, marker = 'o')
plt.plot(11, 10.5, marker = 'o')
plt.plot(2, 10.5, marker = 'o')
#draw line in doubles sideline area
plt.plot([2, 11, 11, 2, 2], [2.5, 2.5, 10.5, 10.5, 2.5],linestyle = 'solid', linewidth = 3)
plt.gca().annotate('Doubles Sideline', xy=(8, 10.8), xycoords='data', fontsize=12)
plt.gca().annotate('Baseline', xy=(11.2, 5.5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-2 inch->', xy=(2.7, 10.5), xycoords='data', fontsize=7, rotation=270)
plt.gca().annotate('<---------------------------------------------------------------- \
44 inch | 13.41 m \
------------------------------------------------------------->', xy=(2, 1.2), xycoords='data', fontsize=12)
plt.gca().annotate('<------------------ 20 inch | 6.1 m ------------------->', xy=(11.7, 2.5), xycoords='data', fontsize=12, rotation=270)
#draw bottom points for singles sideline
plt.plot(2, 3.2, marker = 'o')
plt.plot(11, 3.2, marker = 'o')
plt.plot([2, 11], [3.2, 3.2])
#draw right points for singles sideline
plt.plot(10.5, 2.5, marker = 'o')
plt.plot(10.5, 10.5, marker = 'o')
plt.plot([10.5, 10.5], [2.5, 10.5])
#draw top points for singles sideline
plt.plot(2, 9.8, marker = 'o')
plt.plot(11, 9.8, marker = 'o')
plt.plot([2, 11], [9.8, 9.8])
#draw left points for singles sideline
plt.plot(2.5, 10.5, marker = 'o')
plt.plot(2.5, 2.5, marker = 'o')
plt.plot([2.5, 2.5], [10.5, 2.5])
plt.gca().annotate('Singles Sideline', xy=(8, 10), xycoords='data', fontsize=12)
plt.gca().annotate('<-1.5i->', xy=(2.6, 9.8), xycoords='data', fontsize=7, rotation=270)
#net points
#take the middle of doubles sideline bottom points
x = (2 + 11)/2
#print(x)
plt.plot(x, 2.5, marker = 'o')
plt.plot(x, 10.5, marker = 'o')
plt.plot([x, x], [2.5, 10.5])
plt.gca().annotate('Net', xy=(x, 6.5), xycoords='data', fontsize=12, rotation=270)
#left short service line
# point will start from single sideline to net. Then divide into 3 parts.
x1 = (x - 2.5)/3
#print(x1)
x2 = 6.5 - x1
plt.plot(x2, 2.5, marker = 'o', color = 'red')
plt.plot(x2, 10.5, marker = 'o', color = 'red')
plt.plot([x2, x2], [2.5, 10.5])
#right short service line
x3 = 6.5 + x1
plt.plot(x3, 2.5, marker = 'o', color = 'red')
plt.plot(x3, 10.5, marker = 'o', color = 'red')
plt.plot([x3, x3], [2.5, 10.5])
plt.gca().annotate('Short Service Line', xy=(x3 - 0.3, 5), xycoords='data', fontsize=12, rotation=270)
plt.gca().annotate('<-.76 m-->', xy=(2, 3.4), xycoords='data', fontsize=8)
plt.gca().annotate('<--------------- 13 inch | 3.9 m ------------->', xy=(2.5, 3.4), xycoords='data', fontsize=12)
plt.gca().annotate('<-- 6.5 inch | 1.98 m -->', xy=(x2, 3.4), xycoords='data', fontsize=10)
#draw points for left center line
y1 = (2.5 + 10.5)/2
plt.plot(2, y1, marker = 'o')
plt.plot(x2, y1, marker = 'o')
plt.plot([2, x2], [y1, y1])
plt.gca().annotate('Left Service Court', xy=(3, y1 + 1.8), xycoords='data', fontsize=12)
plt.gca().annotate('Center Line', xy=(3.5, y1 + .3), xycoords='data', fontsize=12)
plt.gca().annotate('Right Service Court', xy=(3, y1 - 1.8), xycoords='data', fontsize=12)
plt.gca().annotate('<--8.5 inch | 2.59 m -->', xy=(2.2, y1), xycoords='data', fontsize=10, rotation=270)
#draw points for right center line
plt.plot(x3, y1, marker = 'o')
plt.plot(11, y1, marker = 'o')
plt.plot([x3, 11], [y1, y1])
plt.gca().annotate('Doubles Service Line', xy=(10.6, 6.7), xycoords='data', fontsize=10, rotation=270)
plt.xlim(1, 12)
plt.ylim(1, 12)
plt.title("Badminton Court", fontsize=28, color = 'red')
plt.axis("off")
plt.show()

Output:

Thank for reading.

--

--

Nutan

knowledge of Machine Learning, React Native, React, Python, Java, SpringBoot, Django, Flask, Wordpress. Never stop learning because life never stops teaching.