JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
478 stars 88 forks source link

After some plots displayed in plotspane (Atom) I get an error #409

Closed stakaz closed 6 years ago

stakaz commented 6 years ago

Hello, I am trying to show the plots in the plots pane and it works fine until at some point I get this warning:

ERROR: LoadError: PyError ($(Expr(:escape, :(ccall(#= /home/gluon/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'AttributeError'>
AttributeError("'NoneType' object has no attribute 'f_globals'")
  File "/usr/lib/python3.7/site-packages/matplotlib/pyplot.py", line 516, in figure
    max_open_warning, RuntimeWarning)
  File "/usr/lib/python3.7/site-packages/matplotlib/cbook/__init__.py", line 1995, in _warn_external
    frame.f_globals.get("__name__", "")):

Stacktrace:
 [1] pyerr_check at /home/gluon/.julia/packages/PyCall/0jMpb/src/exception.jl:60 [inlined]
 [2] pyerr_check at /home/gluon/.julia/packages/PyCall/0jMpb/src/exception.jl:64 [inlined]
 [3] macro expansion at /home/gluon/.julia/packages/PyCall/0jMpb/src/exception.jl:84 [inlined]
 [4] __pycall!(::PyCall.PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyCall.PyObject, ::PyCall.PyObject) at /home/gluon/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:44
 [5] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{}, ::Int64, ::PyCall.PyObject) at /home/gluon/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:22
 [6] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{}, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:constrained_layout,),Tuple{Bool}}}) at /home/gluon/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:11
 [7] #pycall#88 at /home/gluon/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:86 [inlined]
 [8] #pycall at ./none:0 [inlined]
 [9] #figure#7(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:constrained_layout,),Tuple{Bool}}}, ::Function) at /home/gluon/.julia/packages/PyPlot/fZuOQ/src/PyPlot.jl:149

I cannot understand what this is all about, can someone help me?

The produced plots are the same so there should be some other reason (maybe to many plots opened at the same time or something like this).

Thanks.

stakaz commented 6 years ago

Ok, the problem was that I have to call plt[:close]() after display(gcf()) in order to not get over 20 plots saved by matplotlib somewhere and kept in memory. Before the last update of julia packages I just had a warning from matplotlib that there are over 20 plots but now this error arises.

tkf commented 6 years ago

This is likely https://github.com/JuliaPy/PyCall.jl/issues/71

cbook._warn_external does not check if frame is None: https://github.com/matplotlib/matplotlib/blob/4dbbd22095e32b77053aab403c442934f18ade71/lib/matplotlib/cbook/__init__.py#L1991-L1998

tkf commented 6 years ago

Its' fixed upstream: https://github.com/matplotlib/matplotlib/pull/12771