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

display() is not defined warning #2407

Closed
nblomberg opened this issue Feb 21, 2020 · 2 comments
Closed

display() is not defined warning #2407

nblomberg opened this issue Feb 21, 2020 · 2 comments

Comments

@nblomberg
Copy link

While using backend PyPlot you get warning on the first run "_display is not defined for this backend." when pyplot() is inside a function. I don't know if this how it is intended to work, but at least the warning could be more helpful. I have no idea why it has problems with display in particular?

using Plots

function main()
    pyplot()
    a = plot(1:10,1:10)
    display(a)
end
main()

This works fine if pyplot() is outside of main().

@BeastyBlacksmith
Copy link
Member

Note that the following works

using Plots

function main()
    pyplot()
    plot(1:10,1:10)
end
p = main()
display(p)

But you need to return to the toplevel between a backend switch and the display, since the backend initialization is in a different world age otherwise

@BeastyBlacksmith
Copy link
Member

A second option is to use Base.invokelatest

using Plots

function main()
    pyplot()
    p = plot(1:10,1:10)
    Base.invokelatest(display, p)
end

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

No branches or pull requests

2 participants