Shared x_axes with make_subplots

I’m new to Plotly. My chart is a grid of subplots labeled 2x3, with the same x and y columns for each subplot. This may be an obvious question, but what’s the most optimal (or easiest) way to align the x and y across subplots in a grid of more than one dimension? The application of shared_xaxes arguments makes sense, but wondering why this doesn’t extrapolate across all subplots.

Also wondering if there is a go.Figure() way.

My plot.

My code.

from plotly.subplots import make_subplots

fig = make_subplots(3, 2, shared_xaxes=True, shared_yaxes=True)

loc = [[1, 1], [1, 2],
[2, 1], [2, 2],
[3, 1], [3, 2]]

cuis = [“American”, “Vietnamese”, “Spanish”, “French”, “Southern”, “Indian”]

for subplot in range(0, 6):
mode=“markers”, name=cuis[subplot],
row=loc[subplot][0], col=loc[subplot][1])

Thanks in advance.

Hi @plotmaster422, I have difficulties to understand your question. :see_no_evil:

What do you mean with this?

Could you explain how you want the plot to look like?

Ah, so in a nutshell, I am attempting to provide the columns with consistency as it pertains to the x axes. The axes are consistent across the first subplot axes, but for some reason, they go out of wack in the next column subplot.

I also understand this may be a more complex issue, so if you can’t find an easy solution, no worries. Thanks for your help!

I feel kind of stupid. Are you talking about the axis range of the left column and right column?

1 Like

Edited: just realized that I misused the param - if the argument is indeed useful for subplot situations, how deeply is that integrated with the go functionality? And back to my original use case, it honestly seems way easier with px. Given functionality limitations. :laughing:

If that is over your head, the specific question is to align the x axis ranges in the two columns of the subplot. shared_x_axes=True does not work for some reason. Is this just an argument thing?

Resolved using for_each. full code snippet shared below

fig.for_each_xaxis(lambda x: x.update(showgrid=False, zeroline=False, range=[0, 1.2]))