For this, I used the JointGrid tool, which allows me to make a multi-plot grid for conditional relationships, where we can show the marginal distributions on the top and right parts of the graph.

The jointplot function has already many things built in, for plotting something like a scatter plot (with x and y variables) while showing its distribution.

In my case, what I wanted to plot wasn’t a scatter plot, It did not have an x nor an y, it was a ol’ heatmap created from a pd.crosstab.

At first, I was going to create a Heatmap and two barplots, but then I decided to try to combine them all into one, and here is the result:

The code to accomplish this was the following:

# _toplot = pd.crosstab(...)# Create an empty joint gridgrid=sns.JointGrid()# Fill the centre with our heatmapsns.heatmap(_toplot,ax=grid.ax_joint,cbar=False,annot=True,fmt='g',cmap='mako')# Draw total bars, both with width 1, but the Y one with horizontal orientationsns.barplot(_toplot.sum(),ax=grid.ax_marg_x,width=1)sns.barplot(_toplot.sum(axis=1),ax=grid.ax_marg_y,orient='h',width=1)# Offset value (just half an unit)_off=.5# Fix x_xmin,_xmax=grid.ax_joint.get_xlim()grid.ax_joint.set_xlim(_xmin+_off,_xmax+_off)forbaringrid.ax_marg_x.containers[0]:bar.set_x(bar.get_x()+_off)# Fix y_ymin,_ymax=grid.ax_joint.get_ylim()grid.ax_joint.set_ylim(_ymin+_off,_ymax+_off)forbaringrid.ax_marg_y.containers[0]:bar.set_y(bar.get_y()+_off)# Need to use this to set the horizontal_alignmentgrid.ax_joint.set_xticklabels(grid.ax_joint.get_xticklabels(),rotation=30,ha='right')grid.ax_joint.yaxis.set_tick_params(rotation=0)grid.ax_joint.set_xlabel('Día de votación')grid.ax_joint.set_ylabel('Día de creación')

Further reading

After coming up with this solution, I found this StackOverflow post: