utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:decoding_challenge_cortana_2016_3rd 作者: kingjr 项目源码 文件源码
def _plot_sensors(pos, colors, ch_names, title, show_names, show):
    """Helper function for plotting sensors."""
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    from .topomap import _check_outlines, _draw_outlines
    fig = plt.figure()

    if pos.shape[1] == 3:
        ax = Axes3D(fig)
        ax = fig.gca(projection='3d')
        ax.text(0, 0, 0, '', zorder=1)
        ax.scatter(pos[:, 0], pos[:, 1], pos[:, 2], picker=True, c=colors)
        ax.azim = 90
        ax.elev = 0
    else:
        ax = fig.add_subplot(111)
        ax.text(0, 0, '', zorder=1)
        ax.set_xticks([])
        ax.set_yticks([])
        fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=None,
                            hspace=None)
        pos, outlines = _check_outlines(pos, 'head')
        _draw_outlines(ax, outlines)
        ax.scatter(pos[:, 0], pos[:, 1], picker=True, c=colors)

    if show_names:
        for idx in range(len(pos)):
            this_pos = pos[idx]
            if pos.shape[1] == 3:
                ax.text(this_pos[0], this_pos[1], this_pos[2], ch_names[idx])
            else:
                ax.text(this_pos[0], this_pos[1], ch_names[idx])
    else:
        picker = partial(_onpick_sensor, fig=fig, ax=ax, pos=pos,
                         ch_names=ch_names)
        fig.canvas.mpl_connect('pick_event', picker)
    fig.suptitle(title)
    plt_show(show)
    return fig
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号