1

I am using the basic axis.annotate(str(i)) function to show values along the points of my graph. The problem is quite quickly they get to bunched together. So I have two questions: How can I remove an annotation? And how can I make one smaller (font size)?

Here is the reference to the annotation method: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.annotate

I have done my research and surprisingly found nothing. Cheers.

harry lakins
  • 803
  • 1
  • 13
  • 28
  • 1
    The problem of bunching annotations has been tackled [here](http://stackoverflow.com/questions/40735808/annotation-auto-placement-matploylib-pyplot-or-list-annotations) and [this question](http://stackoverflow.com/questions/14938541/how-to-improve-the-label-placement-for-matplotlib-scatter-chart-code-algorithm) may be equally of interest. – ImportanceOfBeingErnest Dec 17 '16 at 20:43
  • Looks interesting. Cheers. – harry lakins Dec 17 '16 at 20:43

1 Answers1

6

axis.annotate(str(i)) returns an axes Annotation object. You need to assign a variable to it and then you manipulate it however you want.

fig, ax = plt.subplots(1,1)
ax.plot(range(5))
text = ax.annotate(xy = (2,2), s='asdf')
# use any set_ function to change all the properties
text.set_fontsize(20)
Ted Petrou
  • 59,042
  • 19
  • 131
  • 136