I am drawing a heatmap using plotly in python. I want to draw a rectangle around certain areas and I'm doing it as follows:
import plotly.graph_objs as go
import plotly.figure_factory as ff
layout_heatmap = go.Layout(
xaxis=dict(title='Years'),
yaxis=dict(title='Years'),
)
ff_fig = ff.create_annotated_heatmap(x=all_years, y=all_years, z=heatmap, showscale=True,
colorscale='Viridis',)
fig = go.FigureWidget(ff_fig)
fig.layout = layout_heatmap
fig.layout.annotations = ff_fig.layout.annotations
fig['layout']['yaxis']['autorange'] = "reversed"
fig.add_shape(type="rect",
x0=1960, y0=1960, x1=1966, y1=1966,
line=dict(color="red"),
)
fig.add_shape(type="rect",
x0=1967, y0=1967, x1=1970, y1=1970,
line=dict(color="red"),
)
fig.show()
The output is being as follows:

I dont want the rectangle to pass through the cells, I want an effect like this but its not working:

