As per the block of code below, using ax.annotate()
it appears that the outer extents of the Figure object are not properly captured by figure fraction
. I would expect the arrows to point right to the very corners of the plot, which as per first plot they do not.
Also when the figure plot is created without any of the annotations, it is not the same size - see second plot. The annotations I've used should not change the figure size. I'm using info from this Matplotlib page.
Anyone able to explain these oddities?
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis([0, 10, 0, 10])
bbox_args = dict(boxstyle="round, pad=0.3", fc="w", ec='red', alpha=0.5)
arrow_args = dict(arrowstyle="->")
# figure fraction
ax.annotate('figure fraction : 0, 0', xy=(0, 0), xycoords='figure fraction', xytext=(20, 20),
textcoords='offset points', ha='left', va='bottom', bbox=bbox_args,
arrowprops=arrow_args)
ax.annotate('figure fraction : 1, 1', xy=(1, 1), xycoords='figure fraction', xytext=(-20, -10),
textcoords='offset points', ha='right', va='top', bbox=bbox_args,
arrowprops=arrow_args)
# axes fraction
ax.annotate('axes fraction : 0, 0', xy=(0, 0), xycoords='axes fraction',
xytext=(20, 20), textcoords='offset points',
ha="left", va="bottom", bbox=bbox_args,
arrowprops=arrow_args)
ax.annotate('axes fraction : 1, 1', xy=(1, 1), xycoords='axes fraction',
xytext=(-20, -20), textcoords='offset points',
ha="right", va="top", bbox=bbox_args,
arrowprops=arrow_args)
When no annotations are included i.e. just:
fig, ax = plt.subplots()
ax.axis([0, 10, 0, 10])