Hello.
I’m trying to create a subplot of annotated heatmaps using Dash + Plotly.
Without using annotated heatmaps (from Figure Factory), the following code get what I want:
@rtadewald,
Please inspect your data frame and its column conversions tolist to see what is recorded in the position where no info is displayed. Without data I cannot express any opinion. The code is ok.
This odd behaiour occurs because after fig definition via make_subplots, fig.layout.annotations is already initialized with subplot_titles (my initial example had no titles) .
In this case you have to add the new annotations, read from fig1, fig2, fig3 as follows:
new_annotations = annot1+annot2+annot3
for anno in new_annotations:
fig.add_annotation(anno)
,
When your subpolots contain many cells ,not only 2-3, define new_annotations =[] and extend it by new_annotations.extend(), not by concatenating with +.
Do you know why, using that code, both of my plots are with white color and the centered one with black color?
What’s the logic for Plot.ly painting them differently?
@rtadewald
Plotly maps z-values to a colorscale Depending on the colorscale you are setting in layout.coloraxis, if it is a sequential one, like in the last plot you posted here, the smaller z-values are mapped to lighter colors, while the bigger - to darker colors. Another colorscales have darker colors corresponding to smaller values.
@rtadewald It seems that your z-data are missing in some cells. In one of the them we can see nan as an annotation. You can set 'connectgaps=True` in Heatmap definition to fill those cells with an interpolated color.
On the image, you can see that the right graph is with white text colors (what makes it sometimes illegible), and the other ones are with black and white colors. You can see the same pattern on the first graphs I’ve send here, where you have my code and the data.
Sorry for the misunderstood. Using your code set all colors to ‘black’, but how to make them smart, like the center graph (white text colors to darker background colors, and vice versa)?
Because your colorscale isn’t in this list, you should update annotation font color following the same rule like that implemented in the method get_text_color().