Home > OS >  get_points in sympy plot_implicit
get_points in sympy plot_implicit

Time:10-04

I have been trying of solving an implicit equations using contour plot but I realized it was taking into account the singularities of my equation so I was obtaining wrong graphs. Because of this, I tried sympy.plot_implicit. Fortunately, it works properly but I have not found a proper way to set a label on the graphs produced by sympy.plot_implicit. For this aim, I need to obtain the points used by sympy.plot_implicit for producing its the graphs and use them into matplotlib. This way, I am obtainig correct solutions for my implicit equations and I can easily set labels for the graphs of the solutions. At this moment, I am facing many issues when I try to obtain the point from sympy.plot_implicit, I mean, when I only use sympy.plot there is not any problem but the issues appear when I use sympy.plot_implicit.
I have attached the code, thank you in advance. Best

import matplotlib.pyplot as plt
import sympy as sp
from sympy.abc import x,y,z

def z(x, y):
    return x - y

line = sp.plot(x**2,(x,-1,0), show=False)

#line = sp.plot_implicit(z(x, y), (x, 0, 1), (y, 0, 1), show=False)

x, y = line[0].get_points()

plt.plot(x, y)

plt.show()

CodePudding user response:

You can use the move_sympyplot_to_axes function from sympy plot_implicit with a legend in matplotlib

  • Related