Implicit plot with plots



How do I make an implicit plot with the plots package?

pyplot has a contour function which admits a fourth argument to plot a single level line.
But it does not seem to be implemented in plots.

Contour plot of density function

There is a contour function in Plots. It’s called contour IIRC.


Yes but it does not plot a single level line. Or am I missing something?


There’s lots of stuff in matplotlib that isn’t implemented in Plots yet. To know if your use case is, could you describe (or screenshot) what an implicit contour is?


The following works:

contour(-3:0.01:3, -3:0.01:3, (x,y) -> x^2 + 2y^2, levels=[2.0, 3.0])

But specifying only one level throws an InexactError.
That seems to be a bug.


As @mkborregaard said, we need to know exactly what you want to do. Could you please give the PyPlot command and output?


Hmm, that works in GR but Plotly ignores the level attribute.


So for example if I want to plot the curve given by the implicit equation x^2+y^2 = 1, I can use the following python code.

   import numpy as np
   import matplotlib.pyplot as plt

The result is a circle of radius 1 centered at the origin. Now using the contour function for an implicit plot is as far as I understand a hack.

I can see that sympy has now a proper plot_implicit function that is documented (and live demonstrated) together with its source code here.

Thanks for your help!


One can use or for this task. The latter is a bit slower, but has a slightly easier to use syntax:

using ImplicitEquations, Plots
f(x,y) = x^2 + y^2
plot(f ⩵ 1)  # \Equal[tab]

The SymPy solution can be called from within SymPy.jl, but that would be PyPlot specific.