import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-6,6,1000)
def sf(x):
return np.sqrt(1-x**2) # semicircle
def ef(x):
return 3*sf(x/7) # ellipse
def sh(x):
return 4.2 - .5*x -2.8*sf(.5*x -.5) # shoulders
def bf(x):
return sf(abs(2 - x) - 1) - x**2/11 + .5*x -3 # bottom
cl_x = [0,0.5,0.8,1]
cl_xn = [-x for x in cl_x]
cl_y = [1.7, 1.7, 2.6, 0.9]
def p(f,xmin,xmax, flipy = False):
"symmetric plot across y-axis"
x = np.linspace(xmin, xmax, 100)
y = f(x)
if flipy:
y = -y
p1 = plt.plot(x, y)
x = [-i for i in x]
ax = plt.plot(x, y)
return ax
p(ef,3,7)
p(ef,4,7, flipy = True)
p(sh,1,3)
p(bf,0,4)
plt.plot(cl_x, cl_y)
plt.plot(cl_xn, cl_y)
plt.show()