ImplicitEquations Plot Return Empty Plot

Hi all,

there is a problem with plotting using ImplicitEquations:

using Plots, ImplicitEquations, LaTeXStrings
gr()

f(x,y) = y^2 - 3y - 4 - x
g(x,y) = x+y

plot(f == 0,-5,5, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
	framestyle=:zerolines,
	label="", legend=:topright)
plot!(g == 0,-5,5, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
	framestyle=:zerolines,
	label="", legend=:topright)

it returns empty plot.

I want to plot x = y^2 - 3y - 4, x=-y

anyone can help me?

1 Like

The problem is that ImplicitEquations wants you to use a Unicode operator written using \Equal<tab> on REPL to get the desired effect.

This is the big fear with Unicode, having minutely perceptible source code differences matter. In any case, here is some code that works:

julia> plot(f ⩵ 0, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
               framestyle=:zerolines,
               label="", legend=:topright)

julia> plot!(g ⩵ 0, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
               framestyle=:zerolines,
               label="", legend=:topright)

Note that dropping the range -5,5 is also necessary, since plot is specialized for this operator and seems to use the xlims and ylims to pick range.

Since I only looked at the README at the ImplicitEquations.jl repo, it’s possible a deeper look will show more useful functions to pre-prepare the series for plotting exactly as you wish.

3 Likes

I see why it becomes empty plot back then. Thanks

Why there is a weirdness when I want to fill the left side there is an invisible barrier at x=-5

using Plots, ImplicitEquations

f(x, y) = y^2 - 3y - 4 - x
g(x,y) = x+y

plot(f ⩵ 0, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
               framestyle=:zerolines,
               label="", legend=:topright)
plot!(g ⩵ 0, xtick=-7:1:5, xlims=(-7,5), ylims=(-5,5), 
               framestyle=:zerolines,
               label="", legend=:topright)

plot!((f ≦ 0) & (g ≦ 0), fc=:blues, 
	label="", widen=true)

Capture d’écran_2023-02-06_15-02-09

1 Like

There must be a bug in the recipe, try manually adding the xlims argument:

plot!((f ≦ 0) & (g ≦ 0), xlims=(-7,5), fc=:blues, 
               label="", widen=true)
2 Likes

Yeah, it seems so. Specifically, because g function goes out of the viewport below -5, then it is no longer considered in the set g <= 0 . One way would be to widen the y-range a bit… or to dig out this bug.

There is an issue here: xlims ylims · Issue #45 · jverzani/ImplicitEquations.jl · GitHub

Basically, I need to learn how to get the xlims (and ylims) from the existing graphic in the recipe.

1 Like

One way to hack around this problem is:

julia> plot!((f ≦ 0) & (g ≦ 0), fc=:blues, 
               label="", ylims=(-10,10), xlims=(-10,10), widen=true)

julia> plot!(fc=:blues, 
               label="", ylims=(-5,5), xlims=(-7,5), widen=true)

which draw the right set in the first instance (because of wider lims and then zooms back to the narrower lims.

1 Like

This one suggestion works, thanks a lot!

1 Like