@@ -140,9 +140,11 @@ def order_targets(
140140 ax .grid (axis = 'y' , visible = False )
141141 ax .set_ylabel ('Targets' )
142142 yticklabels = []
143+ # Find minmax
144+ omin , omax = df_ftr ['order' ].min (), df_ftr ['order' ].max ()
143145 # Add neg targets
144146 if neg_names .size > 0 :
145- img = ax .imshow (mat .loc [neg_names ], extent = [0 , 1 , 0 , neg_names .size ], aspect = 'auto' , cmap = neg_cmap , vmin = vmin , vmax = vmax )
147+ img = ax .imshow (mat .loc [neg_names ], extent = [omin , omax , 0 , neg_names .size ], aspect = 'auto' , cmap = neg_cmap , vmin = vmin , vmax = vmax )
146148 yticklabels .extend (list (neg_names )[::- 1 ])
147149 cbar_mappable = ScalarMappable (cmap = neg_cmap , norm = Normalize (vmin = vmin , vmax = vmax ))
148150 pos = ax .get_position ().bounds
@@ -152,22 +154,22 @@ def order_targets(
152154 ax .axhline (y = neg_names .size , c = 'black' , lw = 1 )
153155 # Add pos targets
154156 if pos_names .size > 0 :
155- img = ax .imshow (mat .loc [pos_names ], extent = [0 , 1 , neg_names .size , neg_names .size + pos_names .size ], aspect = 'auto' , cmap = 'Reds' , vmin = vmin , vmax = vmax )
157+ img = ax .imshow (mat .loc [pos_names ], extent = [omin , omax , neg_names .size , neg_names .size + pos_names .size ], aspect = 'auto' , cmap = 'Reds' , vmin = vmin , vmax = vmax )
156158 yticklabels .extend (list (pos_names )[::- 1 ])
157159 cbar_mappable = ScalarMappable (cmap = pos_cmap , norm = Normalize (vmin = vmin , vmax = vmax ))
158160 pos = ax .get_position ().bounds
159- # (left, bottom, width, height)
160161 cax = bp .fig .add_axes ([0.97 , pos [1 ] + (pos [3 ] / 2 ) + .025 , 0.05 , (pos [3 ] / 2 ) - .025 ])
161162 cax .grid (axis = 'y' , visible = False )
162163 bp .fig .colorbar (cbar_mappable , cax = cax , aspect = 5 , shrink = 0.5 , label = '+ target\n values' , location = 'right' )
163164 # Plot labels
164165 ax .set_ylim (0 , n_names )
165166 if has_cbar :
166- ax .imshow (colors , aspect = 'auto' , extent = [0 , 1 , n_names , 1.1 * n_names ], zorder = 2 )
167+ ax .imshow (colors , aspect = 'auto' , extent = [omin , omax , n_names , 1.1 * n_names ], zorder = 2 )
167168 ax .axhline (y = n_names , c = 'black' , lw = 1 )
168169 ax .set_ylim (0 , 1.1 * n_names )
169170 # Format plot
170171 ax .set_yticks (np .arange (n_names ) + 0.5 )
171172 ax .set_yticklabels (yticklabels )
173+ ax .set_xlim (omin , omax )
172174 bp .fig .subplots_adjust (hspace = 0 )
173175 return bp ._return ()
0 commit comments