@@ -32,10 +32,11 @@ def _add_part_bar(ax=None, start=1.0, len_part=40.0, color="blue", bar_height_fa
32
32
ax .add_patch (bar )
33
33
34
34
35
- def _add_part_text (ax = None , text = None , start = 1.0 , len_part = 10.0 , fontsize = None , fontweight = "normal" ):
35
+ def _add_part_text (ax = None , text = None , start = 1.0 , len_part = 10.0 , fontsize = None ,
36
+ fontweight = "normal" , height_factor = 1.3 ):
36
37
"""Place text marking for TMD and JMD sequence parts."""
37
38
bar_height = _get_bar_height (ax = ax )
38
- y = _get_y (ax = ax , bar_height = bar_height , height_factor = 1.3 , reversed_weight = - 1 )
39
+ y = _get_y (ax = ax , bar_height = bar_height , height_factor = height_factor , reversed_weight = - 1 )
39
40
x = start + len_part / 2 # Middle of part
40
41
ax .text (x , y , text ,
41
42
horizontalalignment = 'center' ,
@@ -88,14 +89,15 @@ def add_tmd_jmd_bar(ax=None, x_shift=0, jmd_color="blue", tmd_color="mediumsprin
88
89
89
90
def add_tmd_jmd_text (ax = None , x_shift = 0 , fontsize_tmd_jmd = None , weight_tmd_jmd = "normal" ,
90
91
name_tmd = "TMD" , name_jmd_n = "JMD-N" , name_jmd_c = "JMD-C" ,
91
- tmd_len = 20 , jmd_n_len = 10 , jmd_c_len = 10 , start = 1 ):
92
+ tmd_len = 20 , jmd_n_len = 10 , jmd_c_len = 10 , start = 1 ,
93
+ height_factor = 1.3 ):
92
94
"""Add text labels for TMD and JMD regions."""
93
95
pp = PlotPart (tmd_len = tmd_len , jmd_n_len = jmd_n_len , jmd_c_len = jmd_c_len , start = start )
94
96
jmd_n_start , tmd_start , jmd_c_start = pp .get_starts (x_shift = x_shift )
95
97
exists_jmd_n = jmd_n_len > 0
96
98
exists_jmd_c = jmd_c_len > 0
97
99
if fontsize_tmd_jmd is None or fontsize_tmd_jmd > 0 :
98
- args = dict (ax = ax , fontsize = fontsize_tmd_jmd , fontweight = weight_tmd_jmd )
100
+ args = dict (ax = ax , fontsize = fontsize_tmd_jmd , fontweight = weight_tmd_jmd , height_factor = height_factor )
99
101
_add_part_text (start = tmd_start , len_part = tmd_len , text = name_tmd , ** args )
100
102
if exists_jmd_n :
101
103
_add_part_text (start = jmd_n_start , text = name_jmd_n , len_part = jmd_n_len , ** args )
@@ -131,11 +133,12 @@ def add_tmd_jmd_xticks(ax=None, x_shift=0, xtick_size=11.0, xtick_width=2.0, xti
131
133
132
134
133
135
def highlight_tmd_area (ax = None , x_shift = 0 , tmd_color = "mediumspringgreen" , alpha = 0.2 ,
134
- tmd_len = 20 , jmd_n_len = 10 , jmd_c_len = 10 , start = 1 ):
136
+ tmd_len = 20 , jmd_n_len = 10 , jmd_c_len = 10 , start = 1 , y_max = None ):
135
137
"""Highlight the TMD area in the plot."""
136
138
pp = PlotPart (tmd_len = tmd_len , jmd_n_len = jmd_n_len , jmd_c_len = jmd_c_len , start = start )
137
139
jmd_n_start , tmd_start , jmd_c_start = pp .get_starts (x_shift = x_shift )
138
- y_min , y_max = plt .ylim ()
140
+ y_min , _y_max = ax .get_ylim ()
141
+ y_max = _y_max if y_max is None else y_max
139
142
height = abs (y_min ) + y_max
140
143
rect = mpl .patches .Rectangle ((tmd_start , y_min ), width = tmd_len , height = height , linewidth = 0 ,
141
144
color = tmd_color , zorder = 0.1 , clip_on = True , alpha = alpha )
0 commit comments