Add plot to plotly subplot with new axes

Hey

I’ve been trying to find a way through for some hours now, but I haven’t found a way yet. But I’m sure it is possible.

So, I have a subplot consisting of a non-fixed number of rows but always with two columns. The size of the rows depends on the % share of the data they make up. Let’s say I got three categories which make ut 75%, 5%, and 20% of the data, then the rows will be scaled to that size.

In the first column, I have plotted each user’s input and its distribution over each category as a horizontally stacked bar plot. Each row consists of the users whose data consists mainly of that category.

So far so good. But in the second column I want to plot each categories average values, which is a time series consisting of 24 data points. I would like these to be of the same size and centered, regardless of the data their category makes up.

See image below for current looks and desired ones:

This is how I start the code

        fig = make_subplots(
            rows=number_of_categories_with_a_majority, cols=2,
            row_heights=row_height_weight.tolist(),
            column_widths = [0.8,0.2],
            vertical_spacing = 0.0,
            horizontal_spacing = 0.005,
            subplot_titles=['Cluster user distribution','Typical profile'],
            print_grid=True)

And then I basically just add traces to each row and col

But how can I achieve the desired outcome:? The best would be if it is possible to define a fixed new size of a plot, and add it to a specified normalized coordinate in each subplots, cause then it would be easy to get them of the same size and centered in the middle.

Any ideas?

Thanks

Hey @carfly welcome to the forums.

I do not have much experience with subplots, basically because I don’t like them. I prefer creating a dash app with, in your case 6 single figures, and arrange them as I want them to be.

That said, the subplots on the right hand side column should share a common y axis, this should at least omit the different scaling.

I think I would actually create a single chart with three traces for the line charts and calculate the height manually (programmatically)