# Help! Plots not loading

**URL:** <https://discourse.julialang.org/t/help-plots-not-loading/49941>\
**Category:** General Usage\
**Tags:** question, package, plotting, plots, gr\
**Created:** [November 10, 2020, 8:03pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941 "2020-11-10T20:03:53Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 10, 2020, 10:05pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/21 "2020-11-10T22:05:16Z")

</div>

ok, seems to be where I was before

When I run this

```julia
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.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 10, 2020, 10:11pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/22 "2020-11-10T22:11:48Z")

</div>

> [@brett\_knoss](#):
>
> ```julia
> 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
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 10, 2020, 10:14pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/23 "2020-11-10T22:14:10Z")

</div>

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”)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 10, 2020, 10:14pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/24 "2020-11-10T22:14:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 10, 2020, 10:18pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/25 "2020-11-10T22:18:51Z")

</div>

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

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

```

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

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 10, 2020, 10:27pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/26 "2020-11-10T22:27:34Z")

</div>

The code still doesn’t run

```julia

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

```

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 10, 2020, 10:32pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/27 "2020-11-10T22:32:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 10, 2020, 11:53pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/28 "2020-11-10T23:53:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 10, 2020, 11:54pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/29 "2020-11-10T23:54:20Z")

</div>

Ok thanks.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 1:54am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/30 "2020-11-11T01:54:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 11, 2020, 2:24am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/31 "2020-11-11T02:24:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 2:27am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/32 "2020-11-11T02:27:05Z")

</div>

> [@pdeffebach](#):
>
> ld 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` .

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

should I do :

plot!(f(x,y))

?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 11, 2020, 2:33am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/33 "2020-11-11T02:33:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 2:35am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/34 "2020-11-11T02:35:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)\
**Post date:** [November 11, 2020, 7:22am UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/35 "2020-11-11T07:22:22Z")

</div>

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 🙂 ).  
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.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 8:23pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/36 "2020-11-11T20:23:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 11, 2020, 9:05pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/37 "2020-11-11T21:05:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 9:12pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/38 "2020-11-11T21:12:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [November 11, 2020, 9:49pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/39 "2020-11-11T21:49:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 11, 2020, 10:03pm UTC](https://discourse.julialang.org/t/help-plots-not-loading/49941/40 "2020-11-11T22:03:35Z")

</div>

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

```julia
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.

[Previous page](https://discourse.julialang.org/t/help-plots-not-loading/49941.md?page=1)

[Next page](https://discourse.julialang.org/t/help-plots-not-loading/49941.md?page=3)
