[Python] ValueError: Number of rows must be a positive integer, not GridSpec(2, 1,...

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    Trying to make a 2 row 1 col subplot with gridspec and keep getting the error

    ValueError: Number of rows must be a positive integer, not GridSpec(2, 1, height_ratios=[1, 3])[1:2, 0:1]


    when using code

    fig, ax = plt.subplots(figsize = (8,6))
    gs = gridspec.GridSpec(2,1,height_ratios = [1,3])


    and I cant for the life of me figure out why. I want the subplot on top to be the same width but about 1/3 the height of the plot below.

    Continue reading...

Compartilhe esta Página