1

I have two rows of subpolots but an overall odd amount of plots (2 rows, one with 5 columns and the other with four columns. I would like to have subplots show the first row with 5 columns and the bottom rown with four columns, but I would like the four columns in the bottom row to be stacked like bricks...

| 1 | 2 | 3 | 4 | 5 |  --> row 1
  | 6 | 7 | 8 | 9 |    --> row 2

But I cannot quite figure out how to do this by the docs. Is there anyway to accomplish this?

1 Answer 1

1

Let's try subplot2grid:

fig = plt.figure(figsize=(2*row1,3))

for i in range(row1):
    ax = plt.subplot2grid((2,2*row1), (0,2*i), colspan=2)
    # plot something
    ax.plot([0,1])

for i in range(row1-1):
    ax = plt.subplot2grid((2,2*row1), (1,2*i+1), colspan=2)
    
    #plot something
    ax.plot([0,1])

plt.tight_layout()
plt.show()

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.