I have many linear equations contained in a dataframe and I want to plot these equations in Python, the equations are in this format, for example:
enter image description here
How do I do this automatically?
b = row['b']
λ1 = row['λ1']
λ2 = row['λ2']
restricao = row['Restrições']
if restricao == '<=':
# Se λ1 for zero
if λ1 == 0:
plt.plot([0, 0], [0, b / λ2], linestyle='solid')
# Se λ2 for zero
elif λ2 == 0:
plt.plot([b / λ1, 0], [0, 0], linestyle='solid')
# Se λ2 for zero
elif b == 0:
plt.plot([0, 0], [0, 0], linestyle='solid')
# Se ambos λ1 e λ2 são diferentes de zero
else:
plt.plot([b / λ1, 0], [0, b / λ2], linestyle='solid')
elif restricao == '>=':
# Se λ1 for zero
if λ1 == 0:
plt.plot([0, 0], [0, b / λ2], linestyle='solid')
# Se λ2 for zero
elif λ2 == 0:
plt.plot([b / λ1, 0], [0, 0], linestyle='solid')
# Se λ2 for zero
elif b == 0:
plt.plot([0, 0], [0, 0], linestyle='solid')
# Se ambos λ1 e λ2 são diferentes de zero
else:
plt.plot([b / λ1, 0], [0, b / λ2], linestyle='solid')
New contributor
Moisés Rocha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.