ImplicitPlots.jl icon indicating copy to clipboard operation
ImplicitPlots.jl copied to clipboard

p not defined

Open blegat opened this issue 2 years ago • 3 comments

The error comes from https://github.com/saschatimme/ImplicitPlots.jl/blob/4f4fe9df8b5c30104859e9440b269f09a787358e/src/ImplicitPlots.jl#L67 and can be reproduced with:

julia> using DynamicPolynomials

julia> @polyvar x y;

julia> implicit_plot(x^2 + y^2; xlims=(-2,2), ylims=(-2,2))
ERROR: UndefVarError: p not defined
Stacktrace:
 [1] macro expansion
   @ C:\Users\blegat\.julia\packages\ImplicitPlots\ci4bv\src\ImplicitPlots.jl:67 [inlined]
 [2] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, f::ImplicitFunction{2})
   @ ImplicitPlots C:\Users\blegat\.julia\packages\RecipesBase\6AijY\src\RecipesBase.jl:299
 [3] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
   @ RecipesPipeline C:\Users\blegat\.julia\packages\RecipesPipeline\juxUg\src\user_recipe.jl:38
 [4] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
   @ RecipesPipeline C:\Users\blegat\.julia\packages\RecipesPipeline\juxUg\src\RecipesPipeline.jl:72
 [5] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
   @ Plots C:\Users\blegat\.julia\packages\Plots\gzYVM\src\plot.jl:225
 [6] #plot#182
   @ C:\Users\blegat\.julia\packages\Plots\gzYVM\src\plot.jl:102 [inlined]
 [7] #implicit_plot#13
   @ C:\Users\blegat\.julia\packages\ImplicitPlots\ci4bv\src\ImplicitPlots.jl:82 [inlined]
 [8] top-level scope
   @ REPL[37]:1

blegat avatar Nov 14 '22 14:11 blegat

Obviously this has something to do with

  1. the set of roots of the equation being empty (or just single-valued as in this case $x^2+y^2 = 0$). See also
implicit_plot(x^2 + y^2 + 0.1; xlims=(-2,2), ylims=(-2,2))
  1. the set of roots (the curve) being so large in radius that it does not fit into the area determined by the xlims and ylims. See
implicit_plot(x^2 + y^2 - 10; xlims=(-2,2), ylims=(-2,2))

If none of the two happens, the plot is produced correctly, as in

implicit_plot(x^2 + y^2 - 1; xlims=(-2,2), ylims=(-2,2))

hurak avatar Nov 17 '22 15:11 hurak

Yeah I think this is just a breaking change in the @recipe macro that I didn't catch

saschatimme avatar Nov 17 '22 16:11 saschatimme

@hurak Yes, you can reproduce it with any empty plot I think

blegat avatar Nov 21 '22 12:11 blegat