def plot_openness_by_hour(data: list, period: dict, ax: Axes): """ Plots the openness by hour from the raw data. :param data: Raw data :param period: Period over which to average the openness :param ax: Axes object in which to put the plot :return: None """ num_hrs = 24 # Get data hour_bins = get_openness_by_hour(data, period) # Plot bar chart ax.bar(range(num_hrs + 1), hour_bins) # Decorate the axes ax.yaxis.grid(True, which="both", linestyle="-.") ax.set_xlim(1, num_hrs) ax.set_xticks(range(num_hrs + 1)) ax.set_xticklabels([f"{t:02d}" for t in ax.get_xticks()]) ax.set_yticklabels([f"{o * 100:.1f}{percent()}" for o in ax.get_yticks()]) ax.set_ylabel("Andel åpen") ax.set_xlabel("Tid på døgnet")
def show_reference( query_record: SeqRecord, subject_record: SeqRecord, ax: mpl.axes, ref_central: Optional[int] = None, ) -> mpl.axes: """show the reference of the chromatograph. design: if location is not proviode, do the alignment first @param seq: input SeqRecord of ref """ sitepairs = align_chromatograph( query_record, subject_record, ignore_ambig=True ) sitepairs_indexing = {s.cf_pos: s for s in sitepairs} cf_sites = [int(i.get_text()) for i in ax.get_xticklabels()] matched_sitepairs = [sitepairs_indexing[pos] for pos in cf_sites] for i, peak in enumerate(ax.get_xticks()): ax.text( peak, 1.05, matched_sitepairs[i].ref_base, color="dimgrey", va="bottom", ha="center", alpha=0.85, fontsize="xx-large", fontweight="bold", clip_on=False, ) if ref_central is not None: ref_pos = matched_sitepairs[i].ref_pos - ref_central else: ref_pos = matched_sitepairs[i].ref_pos ax.text( peak, 1.12, ref_pos, color="dimgrey", va="bottom", ha="center", alpha=0.85, fontsize="medium", fontweight="normal", clip_on=False, ) return ax