Hi all,
I’d created a heatmap using a list which can contain None values. This worked fine with a regular heatmap, None squares were not displayed.
When I converted it to an annotated heatmap using figure_factory and create_annotated_heatmap, I recieved the following error:
Traceback (most recent call last):
File "app.py", line 326, in <module>
shows_heatmap(),
File "app.py", line 239, in shows_heatmap
colorscale='Viridis')
File "/[location]/lib/python3.6/site-packages/plotly/figure_factory/_annotated_heatmap.py", line 110, in create_annotated_heatmap
z, x, y, annotation_text, colorscale, font_colors, reversescale, **kwargs
File "/[location]/lib/python3.6/site-packages/plotly/figure_factory/_annotated_heatmap.py", line 292, in make_annotations
z_mid = _AnnotatedHeatmap.get_z_mid(self)
File "/[location]/lib/python3.6/site-packages/plotly/figure_factory/_annotated_heatmap.py", line 279, in get_z_mid
z_min = min([v for row in self.z for v in row])
TypeError: '<' not supported between instances of 'NoneType' and 'int'
On changing the code which creates my lists, such that the None values were replaced with 0, the error didn’t occur, however these obviously now display 0 on the heatmap.
Is there a way to pass in the list containing None values, and have them be accepted? Here’s how I’m calling the function, with example not working data:
months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
years = [2018, 2019]
shows = [[3, 1, 2, 1, 5, 6, 1, 4, 5, 1, 5, 2],[3, 3, 5, 3, 4, 8, 2, 3, None, None, None, None]]
fig = ff.create_annotated_heatmap(z=shows,
y=years,
x=months,
xgap=5,
ygap=5,
connectgaps=False,
colorscale='Viridis')
Thanks in advance!