开发者社区> 问答> 正文

元组索引在散点图中超出范围

我想散点图一个两列数据看起来如下(打印)

0     0.195871-0.008693j  0.117586+0.001306j
1     0.219024+0.003791j  0.132911-0.007069j
2     0.271063-0.009686j -0.135223+0.007258j
3     0.279217-0.010561j  0.174209-0.004157j
4     0.194862+0.017081j  0.108965+0.007829j
...                  ...                 ...
9994  0.398795+0.035182j -0.068538+0.017619j
9995  0.540517+0.059227j -0.250704+0.027940j
9996  0.218166-0.010739j  0.131059-0.008267j
9997  0.285605+0.035444j -0.051080+0.018130j
9998  0.185130+0.009470j  0.113928+0.009426j

[9999 rows x 2 columns]

我不知道上面j是什么意思。无论如何,我写道:

plt.xlabel('LD1')
plt.ylabel('LD2')
plt.scatter(
    X_lda.iloc[:,0],
    X_lda.iloc[:,1],
    c=1,
    cmap='rainbow')

但它将:

/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_axes.py in _parse_scatter_color_args(c, edgecolors, kwargs, xshape, yshape, get_next_color_func)
   4262             try:  # First, does 'c' look suitable for value-mapping?
   4263                 c_array = np.asanyarray(c, dtype=float)
-> 4264                 n_elem = c_array.shape[0]
   4265                 if c_array.shape in [xshape, yshape]:
   4266                     c = np.ma.ravel(c_array)


IndexError: tuple index out of range

问题来源StackOverflow 地址:/questions/59466371/tuple-index-out-of-range-in-scatter-plot

展开
收起
kun坤 2019-12-25 10:00:57 446 0
1 条回答
写回答
取消 提交回答
  • 表格有7列,insert只给了4个值。

    insert(self, index, *args) Similar to Tkinter.Listbox.insert(), except that instead of one string a number of strings equal to the number of columns must be given as arguments. It is an error to specify more or fewer arguments than the number of columns. Returns the ID of the newly created item, as returned by item_create().

    2019-12-25 11:18:40
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载