Facets with different ranges

Hey all,
I am trying to use facets but i have a different number of samples in each facet.
The facets are evenly sized and not sized based on number of samples in them, so I get something like this:

as you can see the bars in the right facet are much wider than the rest, this is even more annoying when having larger differences between facets.

On the internet I found that ggplot in R has the following option to solve this problem:
facet_grid(scales = “free_x”, space = “free_x”)

but could not find such fix in python plotly (preferably plotly express)

Any suggestions?

any ideas?


just to understand your problem:

You want the facet width to be flexible depending on the number of samples so that the bars have the same width?

(As in the second image on the page you linked to)

Yes, exactly.

Hi @alonsht ,

your problem causes me headaches :wink:

I tried messing around with the fig.for_each_xaxis() and adapt the range for each facet, the problem there is, how to get the information about the number of samples.

Maybe you could use make.subplots instead of facets?



Unfortunately I am still facing this issue.
No other suggestions?