How to place the suptitle rotated on the side of the figure

Question:

I’m working with Matplotlib in Python, and have the simple figure-suptitle layout shown below

  Title
----------
|Figure  |
|Pieces  |
----------

The figure pieces are squished a bit, however. To make room, I would like to put the figure suptitle on the side, like so

----------   
|Figure  | (title rotated 90 degrees) 
|Pieces  |
----------

The reason I would like to do this is that there are 47 of these, and each will go on its own 8.5" x 11" page. An alternative would be to rotate the figure itself, although I imagine that might be harder.

Asked By: David McKnight

||

Answers:

import matplotlib.pyplot as plt

names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

fig, ax = plt.subplots(3, 1, figsize=(3, 9))

ax[0].bar(names, values)
ax[1].scatter(names, values)
ax[2].plot(names, values)
fig.suptitle('Categorical Plotting', ha='right', va='center', x=1.1, y=0.5, rotation=270)
plt.show()

enter image description here

names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting', ha='right', va='center', x=0.95, y=0.5, rotation=270)
plt.show()

enter image description here

Answered By: Trenton McKinney
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.