From b5615883934cc398962face8d5947d03081e595b Mon Sep 17 00:00:00 2001 From: veghp Date: Thu, 9 Jan 2025 13:14:00 +0000 Subject: [PATCH] Fix #91 --- .../GraphicRecord/MatplotlibPlottableMixin.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/dna_features_viewer/GraphicRecord/MatplotlibPlottableMixin.py b/dna_features_viewer/GraphicRecord/MatplotlibPlottableMixin.py index f3f5601..31d33c6 100644 --- a/dna_features_viewer/GraphicRecord/MatplotlibPlottableMixin.py +++ b/dna_features_viewer/GraphicRecord/MatplotlibPlottableMixin.py @@ -157,7 +157,12 @@ def plot_feature(self, ax, feature, level, linewidth=1.0): head_length = 0.001 else: width_pixel = self._get_ax_width(ax, unit="pixel") - head_length = 0.5 * width_pixel * feature.length / self.sequence_length + head_length = ( + 0.5 + * width_pixel + * feature.length + / (ax.get_xlim()[1] - ax.get_xlim()[0]) + ) head_length = min(head_length, 0.6 * feature.thickness) arrowstyle = mpatches.ArrowStyle.Simple( @@ -274,7 +279,7 @@ def place_annotation( max_label_length, indicate_strand_in_label=False, ): - """"Place an annotation in the figure. Decide on inline vs. outline. + """ "Place an annotation in the figure. Decide on inline vs. outline. Parameters ---------- @@ -464,7 +469,16 @@ def strand_in_label(f): self.plot_feature(ax=ax, feature=feature, level=level) if feature.label is None: continue - (text, overflowing, nlines, (x1, x2,), height,) = self.place_annotation( + ( + text, + overflowing, + nlines, + ( + x1, + x2, + ), + height, + ) = self.place_annotation( feature=feature, ax=ax, level=level, @@ -573,10 +587,17 @@ def plot_legend( text = feature.legend_text if text is None: continue - parameters = dict(label=text, facecolor=feature.color, edgecolor="black",) + parameters = dict( + label=text, + facecolor=feature.color, + edgecolor="black", + ) if include_edge: parameters.update( - dict(linewidth=feature.linewidth, edgecolor=feature.linecolor,) + dict( + linewidth=feature.linewidth, + edgecolor=feature.linecolor, + ) ) if text in features_parameters: previous_parameters = features_parameters[text]