Spaces:
Sleeping
Sleeping
Update tools/parabola_plotter_tool.py
Browse files
tools/parabola_plotter_tool.py
CHANGED
|
@@ -21,18 +21,19 @@ def plot_parabola_graph(a: float, b: float, c: float) -> str:
|
|
| 21 |
try:
|
| 22 |
# Cria uma gama de valores para x
|
| 23 |
x = np.arange(-10, 11, 2)
|
| 24 |
-
|
| 25 |
|
| 26 |
|
| 27 |
# Calcula y usando a fórmula da função quadrática
|
| 28 |
y = a * x**2 + b * x + c
|
| 29 |
-
|
| 30 |
# Monta a string da função para o título
|
| 31 |
function_string = f"{a}x² + {b}x + {c}".replace("+ -", "- ")
|
| 32 |
|
| 33 |
# Configura e cria o gráfico
|
| 34 |
plt.figure(figsize=(8, 6))
|
| 35 |
plt.plot(x, y)
|
|
|
|
| 36 |
plt.ylim(y_min-1, y_max+1)
|
| 37 |
plt.title(f"Gráfico da Parábola")
|
| 38 |
plt.xlabel("x")
|
|
|
|
| 21 |
try:
|
| 22 |
# Cria uma gama de valores para x
|
| 23 |
x = np.arange(-10, 11, 2)
|
| 24 |
+
|
| 25 |
|
| 26 |
|
| 27 |
# Calcula y usando a fórmula da função quadrática
|
| 28 |
y = a * x**2 + b * x + c
|
| 29 |
+
y_min, y_max = y.min(), y.max()
|
| 30 |
# Monta a string da função para o título
|
| 31 |
function_string = f"{a}x² + {b}x + {c}".replace("+ -", "- ")
|
| 32 |
|
| 33 |
# Configura e cria o gráfico
|
| 34 |
plt.figure(figsize=(8, 6))
|
| 35 |
plt.plot(x, y)
|
| 36 |
+
padding = (y_max - y_min) * 0.1
|
| 37 |
plt.ylim(y_min-1, y_max+1)
|
| 38 |
plt.title(f"Gráfico da Parábola")
|
| 39 |
plt.xlabel("x")
|