Python source code
{
import matplotlib.pyplot as plt
import numpy as np
x1 = np.linspace(-2, 2, 1000)
x2_left = np.linspace(-2, 0, 1000)
x2_right = np.linspace(0, 2, 1000)
# right top half semicircle from theorem Pythagoras using y=sqrt(1-x²)
# shift graph right using "x-1"
# create another left top half semicircle at the negative x-axis
# using y(x) and y(-x) or y(|x|)
y1 = np.sqrt(1 - (abs(x1)-1)**2)
# left bottom half sqrt curve line using y=(x)**0.5
# vertical reflection for the graph using y = -1*(x)**0.5
# shift graph left using "x+2"
y2_left = -1*(x2_left+2)**0.5
# create another right bottom half sqrt curve line using
# vertical reflection y = -1*((-x) + 2)**0.5
y2_right = -1*((-x2_right) + 2)**0.5
plt.plot(x1, y1, color="red")
plt.plot(x2_left, y2_left, color="red")
plt.plot(x2_right, y2_right, color="red")
plt.fill_between(x1, y1, color="red")
plt.fill_between(x2_left, y2_left, color="red")
plt.fill_between(x2_right, y2_right, color="red")
plt.text(0.0, -1.0, "Love", fontsize=24, color="blue",
horizontalalignment="center")
plt.title("Love", fontsize=24, color="blue")
plt.xlabel("x axis" + r"$\rightarrow$")
plt.ylabel('y axis' + r"$\rightarrow$")
plt.show()
}
Program output: ❤️
No comments:
Post a Comment