tsne_display.py 文件源码

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

项目:ecogdeep 作者: nancywang1991 项目源码 文件源码
def imscatter(x, y, image, ax=None, color=None, days=None):
    """Scatter image at x, y on scatter graph

    Args:
        x (int): x location of data point
        y (int): y location of data point
        image: PIL image to be displayed
        ax: scatterplot handle
        color (r,g,b,a): if not None, border color
        days (list of int): if not None, select color based on time of datapoint and days contains
                            the days present in dataset
    Returns:
        artists (list of axis artists)
    """
    if ax is None:
        ax = plt.gca()
    try:
        image = plt.imread(image)
    except TypeError:
        # Likely already an array...
        pass

    x, y = np.atleast_1d(x, y)
    artists = []
    cmap = matplotlib.cm.get_cmap('nipy_spectral')
    for x0, y0, im0 in zip(x, y, image):
        if days:
        # Assumes around 700 videos per day
            color = cmap((days.index(int(im0.split("/")[-1].split("_")[1]))*700+int(im0.split("/")[-1].split("_")[2]))/((len(days))*700.0))
    if os.path.exists(im0):
            im = load_img_seq(im0, resize_size=(1,1), color=color)
            im = OffsetImage(im, zoom=2)
            ab = AnnotationBbox(im, (x0, y0), xycoords='data', frameon=frameon)
            artists.append(ax.add_artist(ab))
    ax.update_datalim(np.column_stack([x, y]))
    ax.autoscale()
    return artists
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号