How to make hexbin plots from a data file using seaborn?
Question: I'm pretty new to using matplotlib and seaborn, and I couldn't really find any
"for dummies" guides on how to do this. I keep getting error messages trying
to use code from the guides I can find. I guess I'm having difficulty taking
their pieces of code and knowing how to apply it to my problem.

I'd like to make a plot like the ones here:
[1](http://stanford.edu/~mwaskom/software/seaborn/tutorial/distributions.html)
and
[2](http://stanford.edu/~mwaskom/software/seaborn/examples/hexbin_marginals.html).
I have a data file with two columns of data ranging from -180 to 180.

This is my attempt at the code:

    
    
    import numpy as np
    import seaborn as sns
    import matplotlib.pyplot as plt
    from scipy.stats import kendalltau
    
    sns.set(style="ticks")
    
    f2 = open("dihs23")
    lines = f2.readlines()
    f2.close()
    x = []
    y = []
    for line in lines:
        p = line.split()
        x.append(float(p[0]))
        y.append(float(p[1]))
    
    
    sns.jointplot(x, y, kind="hex", stat_func=kendalltau, color="#4CB391")
    
    sns.plt.show()
    

Which returns the error

    
    
    Traceback (most recent call last):
      File "heatmap.py", line 30, in <module>
        sns.jointplot(x, y, kind="hex", stat_func=kendalltau, color="#4CB391")
      File "/usr/local/lib/python2.7/dist-packages/seaborn/distributions.py", line 973, in jointplot
        xlim=xlim, ylim=ylim)
      File "/usr/local/lib/python2.7/dist-packages/seaborn/axisgrid.py", line 1133, in __init__
        x = x[not_na]
    TypeError: only integer arrays with one element can be converted to an index
    

I'm guessing there's some aspect to the format of the data that is part of the
problem, but I'm not sure how to fix it.

Thank you for the help!


Answer: Try transforming your `lists` to an `array` with NumPy

    
    
    x_axis = np.asarray(x)
    y_axis = np.asarray(y)
    

