Help! Plots not loading

ok, seems to be where I was before

When I run this

using ModelingToolkit
using Plots
using ImplicitEquations
@variables x y;
f(x,y)= sqrt((x^2+144)+(y^2+144))
 let ex = Differential(x)(f(x, y))
           func_ex = build_function(expand_derivatives(ex), x, y)
           @eval ∂xf(x, y) = ($func_ex)(x,y)
       end

using Plots
using ImplicitEquations
 
plot(∂xf ⩵ 0.1, xlims=(-10, 100), ylims=(-100, 100))
plot!(f ⩵ 0.1, xlims=(-10, 10), ylims=(-100, 100))

it doesn’t give me any error, but it won’t display function f. Not sure if I should put ImplcitEquations first (so it knows x and y are related), I thought I had it working before.

Your code sample doesn’t run, I get Differential not defined.

It would be great if you could make sure the code samples you post work before posting them

As Peter says this doesn’t run, but it looks off to me - f is a function so f == 1 will just return false, and plotting that presumably gives nothing (which is maybe what you’re getting when you say “it won’t display function f”)

If it worked, then I wouldn’t need help.

JK, that part works, I forgot to add ModelingToolkit.jl, I edited it, so it so it should run.

I thought that had to do with the precision of the values of x, without it I get an error.

ERROR: MethodError: no method matching f(::Float64)

I think that means it thinks it’s one number, unless it thinks it’s a num.

The code still doesn’t run


julia> let ex = Differential(x)(f(x, y))
                  func_ex = build_function(expand_derivatives(ex), 1, 1)
                  @eval ∂xf(x, y) = ($func_ex)(x,y)
              end
ERROR: UndefVarError: x not defined

fixed it, I had to add @variables to get ModelToolkit to work. It defines x as a symbol, all syms packages have a version of it. I’ve been working with people familiar with this packge, that would have spotted the mistake. Again, my bad.

Thanks for adding that!

I can get the plots to work, though, so I don’t think I can help much with your plots problem.

Ok thanks.

you got the second plot to work? I remember having a parabola and that sideways parabola (perhaps you can show a pic). I’m not sure why it’s not working for me then.

Sorry, as mentioned by @nilshg, only the first plot works. It creates a sideways parabola.

There is some odd behavior, here. In the second plot, the command f == .1 returns false. It’s not doing anything with an implicit function.

However plots doesn’t error, and it does change the axes making it look like there is a new plot. This is weird, since you explicitely give it the axes.

Regardless, it should be clear why f == 0.1 doesn’t do what you think it’s doing. You haven’t done anything about derivatives of used ImplicitEquations with f. It’s just a normal function.

that makes sense. I thought I’d have to since it has an x and a y

should I do :

plot!(f(x,y))

?

No that most likely will not work. Though I do not know very much about implicit functions.

Could you provide more information on what you would like to accomplish?

I want to plot the implicit derivative, and the original function, which I think is implicit, because x and y aren’t isolated.

Here’s the same error after installing v1.5.3.

Have you ever used PackageCompiler.jl?
I guess it’s probably due to previous precompilation using PackageCompiler.jl (umm… just a guess without any clue :slight_smile: ).
I’m now trying to re-precompile an image using PackageCompiler.jl.
If it works, I’ll share my result.

EDIT: in my case, this resolves the issue.

I just add the package PackageCompiler, and run my plotting just the same?

I think it’s unlikely package compiler will fix your problem.

There are plenty of other steps to do to debug before that. Have you tries running Plots outside of VS Code? In just a plan REPL?

No, I think I remember it working before though, so I could well try it. That would also be a case against something too drastic.

Your function f is never close to 0.1, it being smallest at (0,0), so there are no solutions to Eq(f(x,y),0.1) or f⩵ 0.1. Try again, with a bigger value?

Ok should I make the f or 0.1 greater? Although I can’t test, because now when I try to plot

julia> plot(∂xf ⩵ 0.1, xlims=(0, 10), ylims=(-100, 100))
#I get
ERROR: MethodError: no method matching ⩵(::typeof(∂xf), ::Float64)

Not exactly sure why the type would have changed, from the last time I ran this.