Add `loc=best’ kwarg to pyplot.text()

Hi,
I’m drawing a histogram and I would like to place a text box within the axes that shows the number of events. I like the way I can pass “loc=’best'” to pyplot.legend() and it automatically does its best to avoid my data. Can a new kwarg be introduced to pyplot.text() to provide the same functionality?

ax.text(0.05, 0.95, ‘Entries: ‘ + len(myData),
transform=ax.transAxes, fontsize=14, verticalalignment=’top’,
bbox=dict(boxstyle=’square’, facecolor=’white’))

Author: Fantashit

2 thoughts on “Add `loc=best’ kwarg to pyplot.text()

  1. It might be better to build this into annotation instead of text because text takes an x and a y where as annotation already takes an xy argument. Instead of having to add an extra kwarg (which conflicts positional arguments), xy can just be allowed to take a string (which is relatively easy to switch on if is_stringlike(xy) and xy == 'best': ).

Comments are closed.