3

If I plot a single graph as below, it will be of size (x * y).

import matplotlib.pyplot as plt
plt.plot([1, 2], [1, 2])

However, if I plot 3 sub-graphs in the same row, each of them will be of size ((x / 3) * y).

fig, ax = plt.subplots(1, 3, sharey = True)
for i in range(3):
    ax[i].plot([1, 2], [1, 2])

How can I obtain these 3 subplots, each of which is of size (x * y)?

2
  • 1
    You could make the figure size ((3*x)*y). Commented Jul 17, 2014 at 18:47
  • Thanks. I was thinking if there's a way to specify that i'd like to retain its original size, instead of specifying the size. Commented Jul 17, 2014 at 18:50

1 Answer 1

6

The figure object has a default size that does not know about the number of subplots. You can change the figure size when you make the figure to suit your needs though.

import matplotlib.pyplot as plt

nx = 3
ny = 1

dxs = 8.0
dys = 6.0

fig, ax = plt.subplots(ny, nx, sharey = True, figsize=(dxs*nx, dys*ny) )
for i in range(nx):
    ax[i].plot([1, 2], [1, 2])
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.