Renderer problems using Matplotlib from within a script

后端 未结 2 1221
挽巷
挽巷 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:03

    I ended up installing and using the WXAgg backend; the Agg,and default GTKAgg, didn't work for me.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题