Tow subplots with different heights


I want to create two subplots with these specification:

X axis to be days till 60 days
Y axis for second plot to be 24 hours starting from 1
Y axis for first plot should for 1

I want to create the subplots one above other but when I use update_layout method with height it changes the heights of both the subplots.


Hi @rajaniesh Take a look at this tutorial, please:

Update: To change the height of one of the subplots, you should modify its yaxis domain:

import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np
fig = make_subplots(rows=2, cols=1)
fig.add_trace(go.Bar(y=[2, 3, 1]),
              row=1, col=1)
fig.add_trace(go.Scatter(x = np.random.rand(10),
                         y= np.random.rand(10),
                         mode='markers'), row=2, col=1)

If you are displaying fig.layout you’ll see how the two traces are mapped onto the square [0,1] x [0,1], i.e. in the normalized
space. To change the height of the second cell just modifify yaxis2_domain

    'template': '...',
    'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0]},
    'xaxis2': {'anchor': 'y2', 'domain': [0.0, 1.0]},
    'yaxis': {'anchor': 'x', 'domain': [0.575, 1.0]},
    'yaxis2': {'anchor': 'x2', 'domain': [0.0, 0.425]}

This layout update shrinks the height of the lower subplot:

fig.update_layout(width =700, height=500,
                 yaxis2_domain = [0.2, 0.425])