Search code examples
python-2.7matplotlibpycharm

AttributeError: 'FigureCanvasInterAgg' object has no attribute 'renderer'


I am using Python 2.7 with the error stemming from the lines below:

fig.canvas.draw()
img = np.array(fig.canvas.renderer._renderer)

I have tried all other solutions from changing the backend to WXAgg or GTKAgg and explicitly including matplotlib.use("WXAgg") and it still does not work.

I am running on Fedora as well.

Any suggestions? thanks


Solution

  • Made my account just to answer your question. Here is a quick and dirty fix:

    Insert FigureCanvasAgg.draw(self) to draw() method to class FigureCanvasInterAgg(FigureCanvasAgg) in %PycharmInstallDir%\helpers\pycharm_matplotlib_backend\backend_interagg.py

    I inserted it to line 92 to the version I used. Though not necessary, I suggest making a backup of backend_interagg.py file before modification. The file on my system is read only, so to modify it, you may have to copy it to somewhere else, add this line, and copy it back and overwrite with admin rights.

    As ImportanceOfBeingErnest said, it IS a PyCharm problem: the helper function author overrode draw() method of the FigureCanvasAgg class without maintaining its intended functionality.