Chidwack
Chidwack

Reputation: 367

Disproportionate image subplots in matplotlib

I have been looking at a lot of threads on stack overflow about plot two differently sized images. But all of these posts refer to plots that still end up as either rectangles or squares like the example below.

enter image description here

Is it possible to have a set of subplots that are not equal in length or height? Something along the lines of this?

enter image description here

Upvotes: 1

Views: 454

Answers (1)

Lee
Lee

Reputation: 31090

I'd suggest the add_axes function:

By default there is a canvas with a range 0 to 1 in x and y dimensions. add_axes adds and axis onto this, accepting a rectangle [left,bottom,width,height]. E.g.:

f=plt.gcf()
f.add_axes([0.1,0.8,0.1,0.1],axisbg='g')
f.add_axes([0.25,0.1,0.45,0.8],axisbg='r')
f.add_axes([0.8,0.4,0.15,0.5],axisbg='y')
f.add_axes([0.9,0.2,0.05,0.05],axisbg='b')
f.set_size_inches(10,6)
f.savefig('yourfig.png')

enter image description here

Upvotes: 1

Related Questions