In plotly I am making various plots of the same, but I don't understand why in some subplots my bars are more narrow than in others. I make the subplots either via make_subplots() or via facet_row(), but the result is similar.
The bars in the middle and bottom chart are very narrow and slim if you look close enough. The code I use to generate them is simple:
fig.add_trace(
go.Bar(
x=q.select("date").to_series(),
y=q.select(metric).to_series()
),
row=i+1,
col=j+1,
)
fig.show()
I have checked that the number of dates for each row is of the same orders of magnitude. Any tips?
UPDATE For a reproducible dataset refer to https://gist.github.com/KeremAslan/c20094b65c4023e8b1d8d6b70fe90f45.
The code used to generate the plot
import polars as pl
df = pl.read_csv("https://gist.githubusercontent.com/KeremAslan/c20094b65c4023e8b1d8d6b70fe90f45/raw/bcd44ed1c98ad7021c4b3951e3815d9b22a021a1/stackoverflow_plotly")
values = ["value_a", "value_b", "value_c", "value_d"]
groups = ["A", "B", "C", "D", ""]
fig = make_subplots(
# rows=len(values),
# cols=len(groups),
rows=len(groups),
cols=len(values),
shared_xaxes=True,
shared_yaxes=True
)
for group_index, group in enumerate(groups):
for ix, value in enumerate(values):
p = df.filter(pl.col("group") == group)
fig.add_trace(
go.Bar(
x=df.select("date").to_series(),
y=df.select(value).to_series()
),
row=group_index+1,
col=ix+1
)
fig.update_layout(
showlegend=False
)
fig.show()


