I have the following code:
import sympy as syp
x, y = syp.symbols('x, y')
Equation_1 = - 2*x + y**2 - 5
Equation_2 = x**3 + syp.sin(y) - 10
syp.plot_implicit(syp.Or(syp.Eq(Equation_1, 0), syp.Eq(Equation_2, 0)), (x, -50, 50), (y, -50, 50))
which provides this picture:
Do you know any hack that can be used to change the color of the second curve? I think it's not directly possible, according to Sympy's documentation.
It appears that passing any sort of color argument to the plot_implicit
function is not currently implemented.
This is true regardless of how many functions you are plotting.
I suspect that it is possible to add this functionality, but it is not currently there.
On the other hand this can be done if you are only plotting lines. Here's how:
import sympy as sy
x = sy.symbols('x')
# Make two plots with different colors.
p1 = sy.plot(x**2, (x, -1, 1), show=False, line_color='b')
p2 = sy.plot(x**3, (x, -1, 1), show=False, line_color='r')
# Make the second one a part of the first one.
p1.extend(p2)
# Display the modified plot object.
p1.show()
This is your hack, the .extend()
method of Sympy's Plot
objects
import sympy as syp
x, y = syp.symbols('x, y')
Eq0 = - 2*x + y**2 - 5
Eq1 = x**3 + syp.sin(y) - 10
p0 = syp.plot_implicit(Eq0, (x, -50, 50), (y, -50, 50), show=False)
p1 = syp.plot_implicit(Eq1, (x, -50, 50), (y, -50, 50), show=False, line_color='r')
p0.extend(p1)
p0.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With