I find the behavior of the following image to be surprising.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.text(1.3, 1.3, "ABC", color = 'red')
# Add blue border
#
fig.patch.set_linewidth(3)
fig.patch.set_edgecolor("blue")
fig.text(0, 1, "DEF", color = 'red')
plt.show()
plt.close()
fig.patch.set_linewidth(3)
fig.patch.set_edgecolor("blue")
fig.text(0, 1, "DEF")
plt.show()
plt.close()
When I use plt.text
to add text to the figure beyond the upper limit of 1, the border expands to contain that text in the top right.
The border comes from a fig
method, seemingly using the new bounds of the figure to determine border placement.
However, the fig.text
line, another fig
method, puts the text at the original upper limit, what would have been the upper limit if I had not used the plt.text
line.
Why do these disagree when they come from methods on the same figure object, and how can I get the fig.text
line to automatically consider the additional text?