@@ -16,6 +16,8 @@ def portrait_plot(
16
16
ax = None ,
17
17
annotate = False ,
18
18
annotate_data = None ,
19
+ annotate_textcolors = ("black" , "white" ),
20
+ annotate_textcolors_threshold = (- 2 , 2 ),
19
21
annotate_fontsize = 15 ,
20
22
annotate_format = "{x:.2f}" ,
21
23
figsize = (12 , 10 ),
@@ -61,6 +63,8 @@ def portrait_plot(
61
63
- `annotate`: bool, default=False, add annotating text if true,
62
64
but work only for heatmap style map (i.e., no triangles)
63
65
- `annotate_data`: 2d numpy array, default=None. If None, the image's data is used. Optional.
66
+ - `annotate_textcolors`: Tuple. A pair of colors for annotation text. Default is ("black", "white")
67
+ - `annotate_textcolors_threshold`: Tuple or float. Value in data units according to which the colors from textcolors are applied. Default=(-2, 2)
64
68
- `annotate_fontsize`: number (int/float), default=15. Font size for annotation
65
69
- `annotate_format`: format for annotate value, default="{x:.2f}"
66
70
- `figsize`: tuple of two numbers (width, height), default=(12, 10), figure size in inches
@@ -169,13 +173,14 @@ def portrait_plot(
169
173
sys .exit ("Error: annotate_data has different size than data" )
170
174
else :
171
175
annotate_data = data
172
- annotate_heatmap (
176
+ ax = annotate_heatmap (
173
177
im ,
174
178
ax = ax ,
175
179
data = data ,
176
180
annotate_data = annotate_data ,
177
181
valfmt = annotate_format ,
178
- threshold = (2 , - 2 ),
182
+ textcolors = annotate_textcolors ,
183
+ threshold = annotate_textcolors_threshold ,
179
184
fontsize = annotate_fontsize ,
180
185
)
181
186
@@ -501,6 +506,8 @@ def annotate_heatmap(
501
506
text = ax .text (j + 0.5 , i + 0.5 , valfmt (annotate_data [i , j ], None ), ** kw )
502
507
texts .append (text )
503
508
509
+ return ax
510
+
504
511
505
512
# ======================================================================
506
513
# Portrait plot 2 (two triangles)
0 commit comments