def versus(data, x, y, xlabel="ratio", ylabels=("growth1", "growth2"), outfn="versus"):
    plt.figure(figsize=(12, 6))

    re_data = reconfigure_data(data, x, y)

#    series1 = data[(data[x] > 1)]
#    series2 = data[(data[x] < 1)]
#
#    growth1 = pd.concat([series1[y[0]], series2[y[1]]])
#    growth2 = pd.concat([series1[y[1]], series2[y[0]]])
#    ratio = pd.concat([series1[x], 1 / series2[x]])
#
#    indata = {}
#    indata[xlabel] = ratio
#    indata[ylabels[0]] = growth1
#    indata[ylabels[1]] = growth2
#    re_data = pd.DataFrame(indata)

    plt.subplot(131)
    sns.regplot(x="x", y="y1", data=re_data)
    shared.add_stats(re_data, "x", "y1")
    sns.despine()

    plt.subplot(132)
    sns.regplot(x="x", y="y2", data=re_data)
    shared.add_stats(re_data, "x", "y2")
    sns.despine()

    ax = plt.subplot(133)
    swarm(ax, re_data, ylabels[0], ylabels[1], "growth rate (\si{\per\hour})")

    plt.tight_layout()
    plt.savefig("ParA_inheritance/{0}.pdf".format(outfn))
def plot_representation(data, spnum):
    areas = pd.concat([data.child1_area, data.child2_area])
    totals = pd.concat([data.child1_total, data.child2_total])
    maxes = pd.concat([data.child1_max, data.child2_max])
    d = pd.DataFrame({"area": areas, "total": totals, "max": maxes})

    plt.subplot(spnum)
    sns.regplot(x="area", y="total", data=d)
    shared.add_stats(d, "area", "total", m=False)
    plt.xlabel("Cell Area (um$^2$)")
    plt.ylabel("Total ParA Intensity (AU)")
    sns.despine()

    plt.subplot(spnum + 1)
    sns.regplot(x="area", y="max", data=d)
    shared.add_stats(d, "area", "max", m=False)
    plt.xlabel("Cell Area (um$^2$)")
    plt.ylabel("Maximum ParA Intensity (AU)")
    sns.despine()
def plot_ratios(data, outfn):
    plt.figure()
    plt.subplot(221)
    plt.title("Total Intensity Ratio")
    sns.despine()
    sns.regplot(x="area_ratio", y="child_ratio", data=data)
    # plot regression line
    shared.add_stats(data, "area_ratio", "child_ratio")
    plt.xlabel("area\_ratio")
    plt.ylabel("child\_ratio")
    plt.legend(loc=2)
#    plt.plot(data.length_ratio, data.child_ratio, ls="none", marker=".")

    plt.subplot(222)
    plt.title("Max Intensity Ratio")
    sns.despine()
    sns.regplot(x="area_ratio", y="max_ratio", data=data)
    shared.add_stats(data, "area_ratio", "max_ratio")
    plt.xlabel("area\_ratio")
    plt.ylabel("max\_ratio")
    plt.legend(loc=4)

    plt.subplot(223)
    sns.despine()
    area_rel = data.child_ratio / data.area_ratio
    sns.distplot(area_rel)
    plt.axvline(1, color="k")
    plt.xlabel("child\_ratio / area\_ratio")
    plt.ylabel("Frequency")

    plt.subplot(224)
    sns.despine()
    length_rel = data.max_ratio / data.area_ratio
    sns.distplot(length_rel)
    plt.axvline(1, color="k")
    plt.xlabel("max\_ratio / area\_ratio")
    plt.ylabel("Frequency")

    plt.tight_layout()
    plt.savefig("ParA_inheritance/{0}.pdf".format(outfn))
def sanity_check(data):
    plt.figure()
    plt.subplot(221)
    plt.title("Total Intensity Ratio")
    sns.despine()
    sns.regplot(x="area_ratio", y="child_ratio", data=data)
    shared.add_stats(data, "area_ratio", "child_ratio")
    plt.xlabel("area\_ratio")
    plt.ylabel("child\_ratio")
    plt.legend(loc=2)

    plt.subplot(222)
    plt.title("Max Intensity Ratio")
    sns.despine()
    sns.regplot(x="area_ratio", y="max_ratio", data=data)
    shared.add_stats(data, "area_ratio", "max_ratio")
    plt.xlabel("area\_ratio")
    plt.ylabel("max\_ratio")
    plt.legend(loc=4)

    plt.subplot(223)
    sns.despine()
    area_rel = data.child_ratio / data.area_ratio
    sns.distplot(area_rel)
    plt.axvline(1, color="k")
    plt.xlabel("child\_ratio / area\_ratio")
    plt.ylabel("Frequency")

    plt.subplot(224)
    sns.despine()
    length_rel = data.max_ratio / data.area_ratio
    sns.distplot(length_rel)
    plt.axvline(1, color="k")
    plt.xlabel("max\_ratio / area\_ratio")
    plt.ylabel("Frequency")

    plt.tight_layout()
    plt.savefig("ParA_inheritance/sanity-check.pdf")
def diffusion(spot_data):
    mid = diffusion_data(spot_data, "x_mid")
    new = diffusion_data(spot_data, "x_new")
    old = diffusion_data(spot_data, "x_old")

    plt.figure()
    plt.subplot(131)
    plt.title("Mid")
    sns.regplot(x="delta_t", y="delta_x2", data=mid)
    shared.add_stats(mid, "delta_t", "delta_x2")
    plt.subplot(132)
    plt.title("New")
    sns.regplot(x="delta_t", y="delta_x2", data=new)
    shared.add_stats(new, "delta_t", "delta_x2")
    plt.subplot(133)
    plt.title("Old")
    sns.regplot(x="delta_t", y="delta_x2", data=old)
    shared.add_stats(old, "delta_t", "delta_x2")
    plt.tight_layout()
    plt.show()