Heatmaps with padding gaps in Plotly

This post will introduce you to xgap and ygap fields for Plotly Heatmaps.

You can set horizontal and vertical gap (in pixels) between the heatmap bricks using these fields.

We will create two different plots, one with the padding and another without it.
The plots will show events per weekday and time of day.

We are using randomly generated data to use in the plots.

The variable hours represents the hours in a day.

The variable days represents all the days in a week.

Using the randint function, we will generate the events in the range from 1000 to 1800.

Heatmap without padding

Heatmap with padding

We are setting both horizontal and vertical padding of 5 pixels.