def add_genotype_annotations_to_plot( self, ax: Axes, points: Dict[str, Tuple[float, float]], annotations: Dict[str, List[str]], color_palette: Dict[str, str]) -> Axes: locations = list() for genotype_label, point in points.items(): if genotype_label == self.root_genotype_name: # There's no point in adding an annotation for the root genotype. continue genotype_color: str = color_palette[genotype_label] genotype_annotations: List[str] = annotations.get( genotype_label, []) if not genotype_annotations: # No annotations for this genome. Don't draw anything. continue background_properties = self._get_annotation_label_background_properties( genotype_color) label_properties = self._get_annotation_label_font_properties( genotype_color) if locations: x_loc, y_loc = relocate_point(point, locations) else: x_loc, y_loc = point locations.append((x_loc, y_loc)) ax.text(x_loc, y_loc, "\n".join(genotype_annotations), bbox=background_properties, fontdict=label_properties) return ax
def _draw_subplot(subplot: Subplot, ax: Axes, start: datetime.datetime, end: datetime.datetime): data_series = [line.load(start, end) for line in subplot.lines] for line, data in zip(subplot.lines, data_series): _draw_series(data, ax, line) if subplot.ylim: if np.isfinite(subplot.ylim[0]): ax.set_ylim(bottom=subplot.ylim[0]) if np.isfinite(subplot.ylim[1]): ax.set_ylim(top=subplot.ylim[1]) ax.set_ylabel(subplot.ylabel, fontsize=subplot.plot.fontsize(1.2)) # Show log book entries for the logsite of this subplot # Draw only logs if logsite is a site of the subplot's lines if subplot.logsite in [l.siteid for l in subplot.lines]: # Traverse logs and draw them for logtime, logtype, logtext in subplot.get_logs(): x = np.datetime64(logtime) ax.axvline(x, linestyle='-', color='r', alpha=0.5, linewidth=3) ax.text(x, ax.get_ylim()[0], logtype, ha='left', va='bottom', fontsize=subplot.plot.fontsize(0.9)) ax.set_xlim(subplot.plot.start, subplot.plot.end) for xtl in ax.get_xticklabels(): xtl.set_rotation(15) ax.yaxis.set_major_locator(MaxNLocator(prune='upper')) ax.tick_params(axis='both', which='major', labelsize=subplot.plot.fontsize(1.1)) ax.grid() ax.legend(loc=0, prop=dict(size=subplot.plot.fontsize(1)))
def key_russian_dates(self, ax: _figure.Axes): pass ''' Draws key dates from Russia on plot as vertical lines and spans. ''' for (date, length, name) in self.__dates.get_key_russian_dates(): x = None if length == self.__dates.to_Timedelta(1): ax.axvline(date, color='Gray', alpha=0.6) x = date else: ax.axvspan(date, date + length, color='Gray', alpha=0.6) x = date + length / 2 ax.text(s=name, x=x, y=ax.get_ylim()[1] * .95, rotation=90, ha='center', va='top', fontsize='small', bbox=dict(boxstyle="square,pad=0.6", fc="white", ec=(0.7, 0.7, 0.7), lw=2))