Closed
Description
Bug report
Bug summary
horizontalalignment = 'left'
aligns the title on the right, horizontalalignment = 'right'
aligns a short title on the left, horizontalalignment = 'right'
displaces a longer title on the far left
Code for reproduction
# Left alignment test, short title
fig = plt.figure(figsize=(9,4))
ax = fig.add_subplot(111)
fig.suptitle('This figure suptitle should be on the left', horizontalalignment = 'left')
ax.set_title('This axis title should be on the left', loc='left');
fig.savefig('left_align.png')
# Right alignment test, short title
fig = plt.figure(figsize=(9,4))
ax = fig.add_subplot(111)
fig.suptitle('This figure suptitle should be on the right', horizontalalignment = 'right')
ax.set_title('This axis title should be on the right', loc='right');
fig.savefig('right_align.png')
# Right alignment test, longer title
fig = plt.figure(figsize=(9,4))
ax = fig.add_subplot(111)
fig.suptitle('This figure suptitle should be on the right but it is far left', horizontalalignment = 'right')
ax.set_title('This axis title should be on the left', loc='left')
fig.savefig('far_left.png');
Actual outcome
Expected outcome
The following code manually sets the figure title at the expected position:
fig = plt.figure(figsize=(9,4))
ax = fig.add_subplot(111)
fig.suptitle('This figure suptitle is long but it is manually positioned', x = 0.38)
ax.set_title('This axis title should be on the left', loc='left')
fig.savefig('manual_pos.png');
Matplotlib version
- Operating system: Windows
- Matplotlib version: 2.1.2 and 2.2.3
- Matplotlib backend: agg
- Python version: 3.6.4
- Jupyter version: 4.4.0