Categorical x axis in Scatter plots

Hello help,

I have two subplots consisting of a scatter plot and a bar plot. Although I have shared_xaxes set to True when the subplots are made, the x axes of the two pots do not line up when the scatter plot mode is set to ‘markers’ or ‘markers+lines’. However, if the mode is set to ‘lines’, the two axes do line up nicely. Note that the scatter plot has two traces: a contour and a scatter trace. The same problem occurs even if I don’t plot the contour trace.

See attached screen shots for the difference I am describing. Thanks a lot in advance for your tips. Below are the settings for the axes:

fig.update_xaxes(fixedrange=True, type=‘category’, showgrid=False, showticklabels=False, row=3, col=1)
fig.update_xaxes(fixedrange=True, type=‘category’, showgrid=False, tickangle=-45, showticklabels=True, row=4, col=1)
fig.update_yaxes(showgrid=False, anchor=‘x’)

The first two rows of the subplots are a Scattermapbox which is not included in the screen shots.

Hey @jimy, I’m not sure if this is applicable in this case, but maybe the sync argument for the tickmode helps?

Thank you. I could not open the link. It says it is private. Anyway, I just tried it but it did not change how the axis behaves. My solution right now is to either set molde=‘lines’, or plot a dummy invisible scatter trace on top of the bar plot in the bottom panel, which forces the bottom axis to be shrank the same way as the axis in top panel does.

I appreciated your help.