Setting spacing between stacked subplots

I have stacked subplots with a shared x-axis. My preferred formatting is to have a box around each plot area and to have the top of one subplot align with the bottom of the subplot above it. An example from matplotlib is shown in the first image below. In matplotlib this is simply achieved with a call of fig.subplots_adjust(h_space=0). Regardless of the line thickness, the axes align nicely so that the bottom axis of one plot overlaps exactly with the top axis of the next plot.
sphx_glr_ganged_plots_001

By default, plotly includes vertical spacing, as shown below.

I assumed that using make_subplots with vertical_spacing=0 would give similar behavior. For small linewidths, it seems to work, but for a thicker linewidth, it’s clear that the axes are not overlapping exactly, leading to an extremely thick line between the stacked axes (see the two images below).


Ideally, I would like to create a template that allows me to set the spacing in such a way that these axes all line up nicely when creating stacked plots like this. I thought perhaps the layout.grid.ygap parameter would allow me to do that, but it doesn’t seem to affect the vertical spacing of the plots when make_subplots is called.

Can anyone make a suggestion for a template setting that would allow me to generate plots this way? And if not via a template, how would I go about adjusting the spacings in the make_subplots call or using update_layout.

Edit: As a side note, I think that the magic value using make_subplots is vertical_spacing=1.25*linewidth/height. I’m not sure why the factor of 1.25 is the magic number, as I would have guessed it would be a full or half linewidth or full linewidth. This isn’t my ideal situation as it requires getting the axis linewidth, which I’m not sure how to do.