daleroberts / itermplot

An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seaborn support: 'FigureCanvasItermplotPdf' object has no attribute 'get_renderer'

cbarrick opened this issue · comments

I get the following error when trying to plot a heatmap with seaborn:

AttributeError: 'FigureCanvasItermplotPdf' object has no attribute 'get_renderer'

Here's a minimal example with the full error message:

>>> import pandas as pd

>>> import seaborn as sns

>>> df = pd.read_csv('results/lag_vs_forecast-2018-06-20T11:43:06.csv')

>>> piv = df.pivot('forecast', 'lag', 'mean_test_score')

>>> sns.heatmap(piv)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-5e2b2acd9fa7> in <module>()
----> 1 sns.heatmap(piv)

~/conda/lib/python3.6/site-packages/seaborn/matrix.py in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, xticklabels, yticklabels, mask, ax, **kwargs)
    526     if square:
    527         ax.set_aspect("equal")
--> 528     plotter.plot(ax, cbar_ax, kwargs)
    529     return ax
    530

~/conda/lib/python3.6/site-packages/seaborn/matrix.py in plot(self, ax, cax, kws)
    313
    314         # Possibly rotate them if they overlap
--> 315         ax.figure.draw(ax.figure.canvas.get_renderer())
    316         if axis_ticklabels_overlap(xtl):
    317             plt.setp(xtl, rotation="vertical")

AttributeError: 'FigureCanvasItermplotPdf' object has no attribute 'get_renderer'

I can't post the CSV publicly, but I don't think it's necessary anyway.

Edit: Calling plt.show() after the error still works and shows the heatmap, but the plot is not cleared. Future plots are drawn on top of the heatmap.

I'm drawing plots on a remote Ubuntu machine, which I've connected to over SSH and using iTerm2's tmux integration.

This seems to be due to this bug. You can try doing export ITERMPLOT_PLOTFILE="plot.png" to change the backend to the PNG one. I've actually changed the default to be PNG in the latest version of itermplot so if you upgrade this issue should be fixed.