Animation fails in frame()

I am trying to build an animation from a double-loop that goes through every hour then every minute of a day, constructing a simulated image.

When my code gets to this line:


it dies with the error at the end of this message. I have tried plotly, pyplot, and plotlyJS backends. I can make successful plots with each backend, but making an animation frame fails.

I apologize if this is a silly question. I am new to Julia and seem to be endlessly banging my head over errors that are just opaque to me as a newbie.

Any advice?


ERROR: MethodError: no method matching _show(::IOStream, ::MIME{Symbol(“image/png”)}, ::Plots.Plot{Plots.PyPlotBackend})
The applicable method may be too new: running in world age 26137, while current world is 26222.
Closest candidates are:
_show(::IO, ::MIME{Symbol(“image/png”)}, ::Plots.Plot{Plots.PyPlotBackend}) at C:\Users\brad.julia\packages\Plots\Ih71u\src\backends\pyplot.jl:1395 (method too new to be
called from this world context.)
_show(::IO, ::MIME{Symbol(“text/html”)}, ::Plots.Plot) at C:\Users\brad.julia\packages\Plots\Ih71u\src\output.jl:163
_show(::IO, ::MIME{Symbol(“text/plain”)}, ::Plots.Plot) at C:\Users\brad.julia\packages\Plots\Ih71u\src\output.jl:205


The problem was at the beginning of the routine. I swapped these two lines so that I created the animation object before selecting a backend. I don’t fully understand what’s going on but wanted to post in case it helps someone else.

anim = Plots.Animation()


Well, now I’m losing my mind. I was getting world age problems again, all of a sudden, it seemed like.

I’ve now changed my code to this, and the world age problems went away.

anim = Plots.Animation()

Since you are not getting any responses to your original question, consider the advice in

particularly: quote your code, provide an MWE, with version information

I think I am getting an inkling as to the “world age” problem.

It had to do with my naivete about Julia variable scope.

I haven’t had time to reproduce the details, but I think what was happening is something like


  for [someloop]
    plt = KeepAddingToPlot(somestuff)


That’s not it exactly - that leads to an obvious failure with plt undefined.

But I think there’s a more subtle variant of this where the code at the end of the loop tries to access a “dated” backend with stuff related to a backend that only “exists” in the for loop.

It’s a very subtle error that I don’t completely understand, and I don’t have time to develop a Minimum Working Example of the error, but I fiddled and futzed and made the problem go away, and it seems like I don’t run into problems if I’m “clean” with declaring the backend, and then add objects to a plot, in the same scope in which I call Plots.gui().

On the one hand, this is a usage error on my part.

On the other hand, this is a pretty subtle error, and I wanted to document it, because, if there’s a right way and a wrong way to use Plots.[backend]() and the other methods of Plots, we should probably explain that at the top level of the Plots.jl docs.

I think you may just be running into local vs global scope, and want something like

for x in xs
    global plt = ...

if you are running at toplevel.

There is no indication that it is, or that it has anything to do with Plots. And this behavior is of course documented.

This is a common sentiment, but I think that people generally just waste more time banging their heads against the wall trying to solve something than it would have taken to come up with an MWE. Of course, YMMV.

Yes, the local versus global scope behavior is documented.

But the error message is quite obscure.

For someone who’s just trying to get started with plots, a message about world age is completely baffling, when the real problem is local versus global scope.

My comment is that it would be of benefit for the Plots.jl documentation to cover this case, because it is sure to trip up lots of newbies.

That was my point, really, in making this post, to try to help people that are confused by a really obscure message that really comes down to something as simple as variable scope.

Variable scope is something that is common across all languages. “World age” is something that I’ve never seen until Julia. It’s the kind of thing that can send a prospective a adopter of the language running for the hills. My thinking is that we should try to knock these things down one at the time, and eliminate the barriers to entry, so we can grow our user base.

It’s nice that you are trying to help others, but this is not the way to do it.

Frankly, I still have no idea what your original problem was. I suspect it was not just one thing: in addition to the global/local scope issue, you had something else going on; which may have been a bug (possibly #2000), a broken installation, or something else.

But without an MWE, there is little chance of fixing, or even diagnosing this. Just posting error messages without context and not following up with an MWE or a bug report is not really that helpful. For a positive example, look at the bug report I linked: it has an MWE (a one-liner!), and receives a reply that at least suggests a workaround.

1 Like

I’m saying that I think the fix, for now, may simply be documentation. Meanwhile, the second best way to help people is to create a note on the internet, “I had this problem and this is how I resolved it”.

I simply posted the thing that I wish someone else had posted before me.

I just have a problem to solve, for a customer. I cannot spare a lot of cycles to fix the Julia language, packages, or environment. But I am willing to offer what aid I can to the next person who comes along, by taking an hour to document my experience.

I did a lot of searching for “Julia Plots World Age Error” and found nothing in any of the docs or any of the discourses. I posted something that would have saved me about 10 hours if I had found it. I simply hope it helps someone else. I would love to have time to really dig in and make things better in the way you suggest, but that is not what my customer is paying me to do. I did what I could by documenting my experience and hope that it helps someone else.

If someone had done this for me, it definitely would have helped me.

These things usually just take very little extra time. Most people feel that they can spare that, especially if they get help from an open source community in return.

My point was that without digging into things a bit, an error message without context is frequently just noise.

There are established, reasonable procedures for tracking down bugs in the Julia community (like most open source projects): you respond to follow-up questions, make an effort to come up with an MWE, open an issue, and possibly even make a PR. Yes, no one pays you for it in cash, it’s s gift exchange economy. And of course no one is forcing you to do it, it’s just being nice.