@@ -57,46 +57,50 @@ def create_annotated_heatmap(
57
57
** kwargs ,
58
58
):
59
59
"""
60
- **deprecated**, use instead
61
- :func:`plotly.express.imshow`.
60
+ **Deprecated**. Use [`plotly.express.imshow`][plotly.express.imshow] instead.
62
61
63
- Function that creates annotated heatmaps
62
+ Function that creates annotated heatmaps.
64
63
65
64
This function adds annotations to each cell of the heatmap.
66
65
67
- :param (list[list]|ndarray) z: z matrix to create heatmap.
68
- :param (list) x: x axis labels.
69
- :param (list) y: y axis labels.
70
- :param (list[list]|ndarray) annotation_text: Text strings for
71
- annotations. Should have the same dimensions as the z matrix. If no
72
- text is added, the values of the z matrix are annotated. Default =
73
- z matrix values.
74
- :param (list|str) colorscale: heatmap colorscale.
75
- :param (list) font_colors: List of two color strings: [min_text_color,
76
- max_text_color] where min_text_color is applied to annotations for
77
- heatmap values < (max_value - min_value)/2. If font_colors is not
78
- defined, the colors are defined logically as black or white
79
- depending on the heatmap's colorscale.
80
- :param (bool) showscale: Display colorscale. Default = False
81
- :param (bool) reversescale: Reverse colorscale. Default = False
82
- :param kwargs: kwargs passed through plotly.graph_objs.Heatmap.
83
- These kwargs describe other attributes about the annotated Heatmap
84
- trace such as the colorscale. For more information on valid kwargs
85
- call help(plotly.graph_objs.Heatmap)
86
-
66
+ Parameters
67
+ ----------
68
+ z : list of list or ndarray
69
+ z matrix to create heatmap.
70
+ x : list
71
+ x axis labels.
72
+ y : list
73
+ y axis labels.
74
+ annotation_text : list of list or ndarray
75
+ Text strings for annotations. Should have the same dimensions as the z matrix. If no
76
+ text is added, the values of the z matrix are annotated. Default is the z matrix values.
77
+ colorscale : list or str
78
+ Heatmap colorscale.
79
+ font_colors : list
80
+ List of two color strings: [min_text_color, max_text_color] where min_text_color is applied to annotations for
81
+ heatmap values < (max_value - min_value)/2. If font_colors is not defined, the colors are defined logically as
82
+ black or white depending on the heatmap's colorscale.
83
+ showscale : bool
84
+ Display colorscale. Default is False.
85
+ reversescale : bool
86
+ Reverse colorscale. Default is False.
87
+ **kwargs
88
+ Additional keyword arguments passed through to `plotly.graph_objs.Heatmap`.
89
+ These kwargs describe other attributes about the annotated Heatmap trace such as the colorscale.
90
+ For more information on valid kwargs, call `help(plotly.graph_objs.Heatmap)`.
91
+
92
+ Examples
93
+ --------
87
94
Example 1: Simple annotated heatmap with default configuration
88
95
89
96
>>> import plotly.figure_factory as ff
90
-
91
97
>>> z = [[0.300000, 0.00000, 0.65, 0.300000],
92
98
... [1, 0.100005, 0.45, 0.4300],
93
99
... [0.300000, 0.00000, 0.65, 0.300000],
94
100
... [1, 0.100005, 0.45, 0.00000]]
95
-
96
101
>>> fig = ff.create_annotated_heatmap(z)
97
102
>>> fig.show()
98
103
"""
99
-
100
104
# Avoiding mutables in the call signature
101
105
font_colors = font_colors if font_colors is not None else []
102
106
validate_annotated_heatmap (z , x , y , annotation_text )
@@ -173,7 +177,6 @@ class _AnnotatedHeatmap(object):
173
177
def __init__ (
174
178
self , z , x , y , annotation_text , colorscale , font_colors , reversescale , ** kwargs
175
179
):
176
-
177
180
self .z = z
178
181
if x :
179
182
self .x = x
@@ -261,7 +264,6 @@ def get_text_color(self):
261
264
min_text_color = black
262
265
max_text_color = white
263
266
elif isinstance (self .colorscale , list ):
264
-
265
267
min_col = to_rgb_color_list (self .colorscale [0 ][1 ], [255 , 255 , 255 ])
266
268
max_col = to_rgb_color_list (self .colorscale [- 1 ][1 ], [255 , 255 , 255 ])
267
269
0 commit comments