Search⌘ K

Solution: Olympic Logo

Explore how to draw the Olympic logo by plotting five colored circles using Matplotlib and NumPy. Understand how to generate data with sine and cosine functions and apply offsets to create overlapping visual effects. This lesson helps you master basic data visualization techniques with Python libraries.

We'll cover the following...

Solution

You can see the solution to drawing the Olympics logo below:

Python 3.10.4
# Import commands
import matplotlib.pyplot as plt
import numpy as np
# Creating figure
f = plt.figure()
# Initialize time series
t = np.linspace(0, 2*np.pi, 1000)
# Create Yellow Circle
yellow_x = np.cos(t)
yellow_y = np.sin(t)
plt.plot(yellow_x,yellow_y,'-', color='#FDB813', linewidth=10)
# Create Green Circle
green_x = 2.5+np.cos(t)
green_y = np.sin(t)
plt.plot(green_x,green_y,'-', color='#00B248', linewidth=10)
# Create Blue Circle
blue_x = -1.2+np.cos(t)
blue_y = 0.9+np.sin(t)
plt.plot(blue_x,blue_y,'-', color='#027A9F', linewidth=10)
# Create Black Circle
black_x = 1.3+np.cos(t)
black_y = 0.9+np.sin(t)
plt.plot(black_x,black_y,'-', color='black', linewidth=10)
# Create Red Circle
red_x = 3.75+np.cos(t)
red_y = 0.9+np.sin(t)
plt.plot(red_x,red_y,'-', color='red', linewidth=10)
# Set up axis
plt.axis('equal')
plt.axis('off')
# Save Figure
plt.savefig('output/olympic.png')
# plt.show()

Explanation

We use Matplotlib to create a figure and plot five circles on it. The circles are created ...