import matplotlib.pyplot as plt # pip install matplotlib
import numpy as np # pip install numpy
def plot_functions():
x = np.linspace(-10, 10, 100)
functions = [
(lambda x: -2*x + 5, 'y = -2x + 5', 'blue'),
(lambda x: 6*x - 1, 'y = 6x - 1', 'red')
]
fig, ax = plt.subplots(figsize=(10, 6))
for func, label, color in functions:
ax.plot(x, func(x), label=label, color=color)
ax.set_title('График линейных функций')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend()
ax.grid(True)
ax.axhline(y=0, color='k', linestyle='--', linewidth=0.5)
ax.axvline(x=0, color='k', linestyle='--', linewidth=0.5)
plt.show()
if __name__ == '__main__':
plot_functions()
Результат