When I run the following code, I have no issue.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter([1, 2, 3], [4, 5, 6])
fig.text(
0,
1,
s = "ABCD",
ha = "left",
va = "bottom",
transform = fig.transFigure
)
fig.patch.set_linewidth(5)
fig.patch.set_edgecolor("green")
plt.show()
plt.close()
My goal is to have that ABCD
in the top left, higher that everything else in the figure and to the left of everything else in the figure, and that is exactly what happens.
When I run this, there is a problem.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter([1, 2, 3], [4, 5, 6])
ax.set_ylabel("1n2n3n4n5n6n7")
ax.set_title("anbncndnenf")
fig.text(
0,
1,
s = "ABCD",
ha = "left",
va = "bottom",
transform = fig.transFigure
)
fig.patch.set_linewidth(5)
fig.patch.set_edgecolor("green")
plt.show()
plt.close()
The goal is to have the ABCD
higher than everything else in the figure, but the title displays higher than the ABCD
. Likewise, the ABCD
is supposed to be the the left of everything else in the figure, yet the y-axis label is to the left of the ABCD
.
Curiously, the border has no issues adjusting to how wide or how tall the figure gets, just this text label.
How can I get the ABCD
text label to display in the upper left corner, no matter what I do with the axis labels or main titles? I need the bottom of the text to be above everything else in the figure and the right of the text to be to the left of everything else in the figure like I have in the first image.