0

I want to create square subplots which are publication quality using Matplotlib. Currently, I have 2 subplots which are made in a figure of size 8,5 and the X limits for both plots are different.

I would want both the subplots to be of square size rather than the Y axis being taller. Any suggestions ? Alternatively, is there a way where I can explicitly control the ratio of width and height of a subplot in matplotlib?

Below is the sample image which I have right now.

Matplotlib Plot with 2 subplots

1 Answer 1

2

You can explicitly control the figure size, and you can explicitly set the axes' positions within a figure, as a fraction of the figure size.

fig = plt.figure(figsize=(8,4))
ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.8])
ax1.plot(...)
ax2 = fig.add_axes([0.5, 0.1, 0.4, 0.8])
ax2.plot(...)

In addition, you can supply aspect='equal' to functions that create axes (add_axes, add_subplot) to force the axes shape to match the axes scales (not relevant for your linear-log plot).

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.