Renderer problems using Matplotlib from within a script

后端 未结 2 1270
挽巷
挽巷 2021-02-20 06:33

I\'ve narrowed down to this call:

fig.canvas.tostring_argb() #fig=matplotlib.pyplot.figure()

this function raises an AttributeError

2条回答
  •  我在风中等你
    2021-02-20 07:08

    I suspect that you have missed out the call to:

    fig.canvas.draw()
    

    before

    fig.canvas.tostring_argb()
    

    as

    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot
    fig=matplotlib.pyplot.figure()
    fig.canvas.tostring_argb()
    

    fails for me, but

    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot
    fig=matplotlib.pyplot.figure()
    fig.canvas.draw()
    fig.canvas.tostring_argb()
    

    works.

提交回复
热议问题