python - Matplotlib - set pad between arrow and text in annotate function -


How do I set the padding between arrows and text in matlotlib's annotated function? Occasionally the text ends up being very close to the arrow and I want to move them a bit more differently.

Basic example:

  import matplotlib.pyplot as plt plt.annotate ('here it is!', Xy = (- 1, -1), Xytext = (0,0), arrowprops = dict (arrowstyle = '- & gt;', lw = 1.5)) plt.xlim (-10,10) plt.ylim (-10,10) plt.show () < / Code> 

Enter image details here

For fancy arrows you can play with the bbox properties:

  Fig , Ax = plt.subplots (1, 3, figs = (7, 3)) for pad_val = [-5, 0, 5] a, z in z (ax, pad_val): a.annotate ('here it is ! \ Npad = {} '.format (p), xy = (- 1, -1), xytext = (1,1), arrowprops = Dict (arrowstyle = '-> & gt;', fc = "k", ec = "k", lw = 1.5), bbox = dict (pad = p, facecolor = "none", edgecolor = "none") Here's the flaw that you do not add a color behind the annotation; a.set_xlim (-10,10) a.set_ylim (-10,10)  

( facecolor = "none" is mandatory), or arrow I always stick to the border of the frame and it can be ugly and it can be ugly.

HH


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -