Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Plots.animate results in UndefVarError: Animation not defined #2400

Closed
Mofef opened this issue Feb 12, 2020 · 2 comments · Fixed by #2403
Closed

@Plots.animate results in UndefVarError: Animation not defined #2400

Mofef opened this issue Feb 12, 2020 · 2 comments · Fixed by #2403

Comments

@Mofef
Copy link

Mofef commented Feb 12, 2020

Hi,

I noticed if you don't use using Plots but only import Plots, then using @Plots.animate results in

UndefVarError: Animation not defined
Stacktrace:
 [1] top-level scope at /home/mofef/.julia/packages/Plots/h3o4c/src/animation.jl:167
 [2] top-level scope at In[50]:4 

I'm new to Julia and I figured that using is much more commonly used than import. Though as far as I understand, both should work...? (I prefer import while learning because it lets me keep track of where something is coming from)

@daschw
Copy link
Member

daschw commented Feb 16, 2020

Thanks a lot for reporting!

@JeffFessler
Copy link
Contributor

This issue seems still not fully resolved. Here is my MWE:

using Plots: plot, @animate
anim = @animate for i in 1:2
    plot(rand(5))
end

From a user point of view, this code should work because it has specified all of the methods from Plots that appear to be used (plot and @animate).
But the code fails with the error
ERROR: LoadError: UndefVarError: Plots not defined

The culprit is this line of code:

$animsym = Plots.Animation() # init animation object

The work around is to add import Plots to the user code, but it would be more user friendly if the import Plots was built into the @animate macro.
Is it possible to have an import statement with a macro?
If so, I could make a PR.
If not, then the @animate documentation should instruct the user to do import Plots before using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants