I would like to plot implicit equations (of the form f(x, y)=g(x, y) eg. X^y=y^x) in Matplotlib. Is this possible?
I don't believe there's very good support for this, but you could try something like
import matplotlib.pyplot from numpy import arange from numpy import meshgrid delta = 0.025 xrange = arange(-5.0, 20.0, delta) yrange = arange(-5.0, 20.0, delta) X, Y = meshgrid(xrange,yrange) # F is one side of the equation, G is the other F = Y**X G = X**Y matplotlib.pyplot.contour(X, Y, (F - G), ) matplotlib.pyplot.show()
See the API docs for
contour: if the fourth argument is a sequence then it specifies which contour lines to plot. But the plot will only be as good as the resolution of your ranges, and there are certain features it may never get right, often at self-intersection points.
Since you've tagged this question with sympy, I will give such an example.
From the documentation: http://docs.sympy.org/latest/modules/plotting.html.
from sympy import var, plot_implicit var('x y') plot_implicit(x*y**3 - y*x**3)