# Python | Simple Rangoli Example with Matplotlib

In this tutorial, we are going to plot some rangoli drawing in Python using matplotlib.
Submitted by Anuj Singh, on August 21, 2020

Rangoli is an art form where a colored figure is drawn on the floor on festive occasions. India is a very cultural-based country and Rangoli can be found in any house during Diwali. In this article, we are introducing some very basic rangoli figures.

We can plot these figures in python and the following example illustrates the implementation.

Illustrations:

## Python code for simple rangoli example with matplotlib

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

n_angles = 36

angles = np.linspace(0, 2 * np.pi, n_angles, endpoint=False)
angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1)
angles[:, 1::2] += np.pi / n_angles

triang = tri.Triangulation(x, y)

y[triang.triangles].mean(axis=1))

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
ax1.triplot(triang, 'b-', lw=1)
ax1.set_title('Drawing Example 1')
ax1.axis(False)

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
ax1.triplot(triang, 'g.-', lw=1)
ax1.set_title('Drawing Example 2')
ax1.axis(False)

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
ax1.triplot(triang, 'yo-', lw=1)
ax1.set_title('Drawing Example 3')
ax1.axis(False)

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
ax1.triplot(triang, 'r.', lw=1)
ax1.set_title('Drawing Example 4')
ax1.axis(False)

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
ax1.triplot(triang, 'g:', lw=1)
ax1.set_title('Drawing Example 5')
ax1.axis(False)
```

Output:

```Output is as Figure
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates