import matplotlib.pyplot as plt
import numpy as np
print('''Available options:
1) straight line
2) Parabola
3) Hyperbole
4) Cubic parabola
5) Parabola branches down
6) Negative hyperbole
7) Sinusoid
8) Cosine''')
a = int(input("Select the function graph: "))
fig, ax = plt.subplots()
ax.set_xlabel('x')
ax.set_ylabel('y')
f = int(input("Введите x: "))
if f < 0:
x = np.linspace(f, abs(f), 100)
else:
print("x Нужно вводить отрицательный")
ax = plt.gca()
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
match a:
case 1:
y = x + 3
ax.plot(x, y)
plt.show()
case 2:
y = x**2
ax.plot(x, y)
plt.show()
case 3:
y = 1 / x
ax.plot(x, y)
plt.show()
case 4:
y = x**3 + 2*x + 2
ax.plot(x, y)
plt.show()
case 5:
y = -(x**2)
ax.plot(x, y)
plt.show()
case 6:
y = -(1 / x)
ax.plot(x, y)
plt.show()
case 7:
y = np.sin(x)
ax.plot(x, y)
plt.show()
case 8:
y = np.cos(x)
ax.plot(x, y)
plt.show()
case _:
print("You have entered a non-existent value")
The graph at the same time should shift from the user's input coordinates. I think it can be done using matplotlib but I don't understand how. At the same time, it is desirable to keep all the graphs that I have, just make them move along the x-axis and y-axis.......................................................................