Seaborn matplotlib: Cannot get window extent w/o renderer (RuntimeError)

后端 未结 1 687
暗喜
暗喜 2021-01-20 00:35

I\'m trying to plot a seaborn clustermap (it doesn\'t work with the heatmap too) with the following, no NaNs admitted:

import nump         


        
相关标签:
1条回答
  • 2021-01-20 01:25

    I'm using Mac OS X 10.9.5, python 2.7.9, matplotlib 1.4.3, and seaborn 0.5.1. I was able to reproduce the error.

    By default I am using the macosx backend for matplotlib. Your code works if I change the backend to qt4agg (requires PyQt4), tkagg or webagg. Here's the script that worked for me:

    import numpy as np
    import pandas as pd
    
    import matplotlib
    matplotlib.use('qt4agg')  # Can also use 'tkagg' or 'webagg'
    
    import matplotlib.pyplot as plt
    import seaborn as sns
    
    
    def plotClusterMap():
        a = pd.DataFrame(np.matrix('1 2; 3 4'))
        print a
        # fig = plt.figure()
        sns.clustermap(a)
        plt.show()
    
    
    if __name__ == "__main__":
        plotClusterMap()
    

    Note that I commented out fig = plt.figure(). clustermap appears to create its own figure.

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