import numpy as np
import matplotlib.pyplot as plt
def clip(ys, limit):
return np.ma.masked_where(np.abs(ys) > limit, ys)
lim = 8
size = 5.6
fig, ax = plt.subplots(figsize=(size, size))
xs = np.linspace(-lim, lim, 1000)
ax.plot(xs, clip(1 / np.sinh(xs), lim * 2), label="y = csch(x)",
color="#b30000", linestyle="-", linewidth=2)
ax.plot(xs, 1 / np.cosh(xs), label="y = sech(x)",
color="#00b300", linestyle="--", linewidth=2)
ax.plot(xs, clip(1 / np.tanh(xs), lim * 2), label="y = coth(x)",
color="#0000b3", linestyle="-.", linewidth=2)
ax.set_xlim(-lim, lim)
ax.set_ylim(-lim, lim)
ax.set_xticks([-1, 0, 1])
ax.set_yticks([-1, 0, 1])
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.grid("on")
ax.legend(loc="lower right")
fig.tight_layout()
fig.savefig("csch_sech_coth.svg", transparent=True)