Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Multiple Annotated Heatmaps Python

I have crated a heatmap by creating a matrix file (.csv). However the z value in the original file is the number of complaints I need displayed and I needed to use another file (.csv) to label the individual cells. I would like to have multiple heat maps on one page because each heatmap shows a different year. My code is below.

import plotly
from plotly import tools
plotly.tools.set_credentials_file()
import plotly.plotly as py
import pandas as pd
import plotly.figure_factory as FF
import plotly.graph_objs as go


#Matrix file contains complaints
df13_14 = pd.read_csv('2013-14_Heat.csv')
df14_15 = pd.read_csv('2014-15_Heat.csv')

#File contains keymap information DON NOT CHANGE OR ERASE JASMIN
annot_text = pd.read_csv('Hover_b.csv', dtype=object)


#reverse the rows
df13_14_revcol = df13_14.iloc[::-1]
df14_15_revcol = df14_15.iloc[::-1]
annot_text_revcol = annot_text.iloc[::-1]

#Create the annotations

trace1 = FF.create_annotated_heatmap(df13_14_revcol.values.tolist(), 
annotation_text=annot_text_revcol.values.tolist(), colorscale=[[0.0, 'rgb(70,137,102)'], 
                                               [0.25, 'rgb(225, 240, 165)'], 
                                               [0.50, 'rgb(255, 176, 59)'], 
                                               [0.75, 'rgb(182, 173, 38)'], 
                                               [1.0, 'rgb(142, 40, 0)']], font_colors=['black'])

trace2= FF.create_annotated_heatmap(df14_15_revcol.values.tolist(), 
annotation_text=annot_text_revcol.values.tolist(), colorscale=[[0.0, 'rgb(70,137,102)'], 
                                               [0.25, 'rgb(225, 240, 165)'], 
                                               [0.50, 'rgb(255, 176, 59)'], 
                                               [0.75, 'rgb(182, 173, 38)'], 
                                               [1.0, 'rgb(142, 40, 0)']], font_colors=['black'])

fig = tools.make_subplots(rows=1, cols=2, 
                          subplot_titles=('Complaints 6/1/2013 - 6/1/2014', 'Complaints 6/1/2014 - 6/1/2015'))

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)
#title
#pt13_14.layout.title= 'Complaints 6/1/2013 - 6/1/2014'

#pt14_15.layout.title= 'Complaints 6/1/2013 - 6/1/2014'
#Output to my plotly account
py.iplot(fig, filename='Complaints append')