def plot_locations(result, offset=0):
    ### Plot the sampled locations for a few neurons
    _, _, _, _, Ls = result
    Ls_rot = []
    for L in Ls:
        R = compute_optimal_rotation(L, pfs, scale=False)
        Ls_rot.append(L.dot(R))
    Ls_rot = np.array(Ls_rot)

    fig = create_figure(figsize=(1.4,2.9))
    ax = create_axis_at_location(fig, .3, 1.7, 1, 1)

    # toplot = np.random.choice(np.arange(K), size=4, replace=False)
    toplot = np.linspace(offset,K+offset, 4, endpoint=False).astype(np.int)
    print toplot
    wheel_cmap = gradient_cmap([colors[0], colors[3], colors[2], colors[1], colors[0]])
    plot_colors = [wheel_cmap((np.pi+pfs_th[node_perm[j]])/(2*np.pi)) for j in toplot]

    for i,k in enumerate(node_perm):
        # plt.text(pfs[k,0], pfs[k,1], "%d" % i)
        if i not in toplot:
            color = 0.8 * np.ones(3)

            plt.plot(pfs[k,0], pfs[k, 1], 'o',
                     markerfacecolor=color, markeredgecolor=color,
                     markersize=4 + 4 * pf_size[k],
                     alpha=1.0)

    for i,k in enumerate(node_perm):
        # plt.text(pfs[k,0], pfs[k,1], "%d" % i)
        if toplot in i:
            j = np.where(toplot==i)[0][0]
            color = plot_colors[j]

            plt.plot(pfs[k,0], pfs[k, 1], 'o',
                     markerfacecolor=color, markeredgecolor=color,
                     markersize=4 + 4 * pf_size[k])



    #     plt.gca().add_patch(Circle((0,0), radius=rad, ec='k', fc="none"))
    plt.title("True Place Fields")
    plt.xlim(-45,45)
    plt.xticks([-40, -20, 0, 20, 40])
    # plt.xlabel("$x$")
    plt.ylim(-45,45)
    plt.yticks([-40, -20, 0, 20, 40])
    # plt.ylabel("$y$")

    # Now plot the inferred locations
    # plt.subplot(212, aspect='equal')
    ax = create_axis_at_location(fig, .3, .2, 1, 1)
    for L in Ls_rot[::2]:
        for j in np.random.permutation(len(toplot)):
            k = node_perm[toplot][j]
            color = plot_colors[j]
            plt.plot(L[k,0], L[k,1], 'o',
                     markerfacecolor=color, markeredgecolor="none",
                     markersize=4, alpha=0.25)

    plt.title("Locations Samples")
    # plt.xlim(-30, 30)
    # plt.xticks([])
    # plt.ylim(-30, 30)
    # plt.yticks([])
    plt.xlim(-3, 3)
    plt.xticks([-2, 0, 2])
    plt.ylim(-3, 3)
    plt.yticks([-2, 0, 2])

    plt.savefig(os.path.join(results_dir, "locations_%d.pdf" % offset))
    # plt.show()
dataset/ETHPy150Open slinderman/pyhawkes/experiments/hippocampus.py/plot_locations/swapped operands of `in`