Python Seaborn JointGrid IndexError

时间:2016-06-21 17:18:36

标签: python numpy matplotlib seaborn

我正在尝试使用每个维度的直方图(使用Seaborn的JointGrid函数在上方和右侧)绘制散点图。

一个非常基本的例子:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.rand(100)
y = np.random.rand(100)
sns.jointplot(x, y, color='r')

但是,我得到以下IndexError:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-42ac8946b390> in <module>()
      1 x = np.random.rand(100)
      2 y = np.random.rand(100)
----> 3 sns.jointplot(x, y, color='r')
      4 

/usr/local/lib/python2.7/site-packages/seaborn/distributions.pyc in jointplot(x, y, data, kind, stat_func, color, size, ratio, space, dropna, xlim, ylim, joint_kws, marginal_kws, annot_kws, **kwargs)
    796     grid = JointGrid(x, y, data, dropna=dropna,
    797                      size=size, ratio=ratio, space=space,
--> 798                      xlim=xlim, ylim=ylim)
    799 
    800     # Plot the data using the grid

/usr/local/lib/python2.7/site-packages/seaborn/axisgrid.pyc in __init__(self, x, y, data, size, ratio, space, dropna, xlim, ylim)
   1640         # Turn off the ticks on the density axis for the marginal plots
   1641         plt.setp(ax_marg_x.yaxis.get_majorticklines(), visible=False)
-> 1642         plt.setp(ax_marg_x.yaxis.get_minorticklines(), visible=False)
   1643         plt.setp(ax_marg_y.xaxis.get_majorticklines(), visible=False)
   1644         plt.setp(ax_marg_y.xaxis.get_minorticklines(), visible=False)

/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in setp(*args, **kwargs)
    348 @docstring.copy(_setp)
    349 def setp(*args, **kwargs):
--> 350     return _setp(*args, **kwargs)
    351 
    352 

/usr/local/lib/python2.7/site-packages/matplotlib/artist.pyc in setp(obj, *args, **kwargs)
   1553         objs = list(cbook.flatten(obj))
   1554 
-> 1555     insp = ArtistInspector(objs[0])
   1556 
   1557     # file has to be popped before checking if kwargs is empty

IndexError: list index out of range

我安装了以下版本:

NumPy 1.12.0.dev0 + cc51ba8

Matplotlib 1.5.2rc2 + 1938.g4ba20b8

Seaborn 0.7.1

我真的很感激有关这里发生的事情的任何见解。谢谢!

1 个答案:

答案 0 :(得分:0)

我降级到Matplotlib 1.5.1并且它现在正在运行。可能是rc2版本中的一些错误?