def lineplot(ax, binfiles, nbins, chr, window, shift, color="br"): assert len(binfiles) <= 2, "A max of two line plots are supported" t = np.arange(nbins) bf = binfiles[0] m = linearray(bf, chr, window, shift) ax.plot(t, m, "{0}-".format(color[0]), lw=2) formatter = ticker.FuncFormatter(lambda x, pos: \ human_readable_base(int(x) * shift, pos)) ax.xaxis.set_major_formatter(formatter) for tl in ax.get_xticklabels(): tl.set_color('darkslategray') label = bf.filename.split(".")[0] perw = "per {0}".format(human_size(window, precision=0)) ax.set_ylabel(label + " " + perw, color=color[0]) if len(binfiles) == 2: ax2 = ax.twinx() bf = binfiles[1] m = linearray(bf, chr, window, shift) ax2.plot(t, m, "{0}-".format(color[1]), lw=2) # Differentiate tick labels through colors for tl in ax.get_yticklabels(): tl.set_color(color[0]) for tl in ax2.get_yticklabels(): tl.set_color(color[1]) label = bf.filename.split(".")[0] ax2.set_ylabel(label + " " + perw, color=color[1]) ax.set_xlim(0, nbins)
def lineplot(ax, binfiles, nbins, chr, window, shift, color="br"): assert len(binfiles) <= 2, "A max of two line plots are supported" t = np.arange(nbins) bf = binfiles[0] m = linearray(bf, chr, window, shift) ax.plot(t, m, "{0}-".format(color[0]), lw=2) formatter = ticker.FuncFormatter( lambda x, pos: human_readable_base(int(x) * shift, pos)) ax.xaxis.set_major_formatter(formatter) for tl in ax.get_xticklabels(): tl.set_color("darkslategray") label = bf.filename.split(".")[0] perw = "per {0}".format(human_size(window, precision=0)) ax.set_ylabel(label + " " + perw, color=color[0]) if len(binfiles) == 2: ax2 = ax.twinx() bf = binfiles[1] m = linearray(bf, chr, window, shift) ax2.plot(t, m, "{0}-".format(color[1]), lw=2) # Differentiate tick labels through colors for tl in ax.get_yticklabels(): tl.set_color(color[0]) for tl in ax2.get_yticklabels(): tl.set_color(color[1]) label = bf.filename.split(".")[0] ax2.set_ylabel(label + " " + perw, color=color[1]) ax.set_xlim(0, nbins)