2
2
from datetime import datetime
3
3
from math import atan2 , degrees
4
4
5
- import matplotlib .pyplot as plt
6
5
import numpy as np
7
6
from matplotlib .container import ErrorbarContainer
8
7
from matplotlib .dates import DateConverter , date2num , num2date
@@ -21,8 +20,8 @@ def labelLine(line, x, label=None, align=True, drop_label=False, **kwargs):
21
20
label : string, optional
22
21
The label to set. This is inferred from the line by default
23
22
drop_label : bool, optional
24
- If True, the label is consumed by the function so that subsequent calls to e.g. legend
25
- do not use it anymore.
23
+ If True, the label is consumed by the function so that subsequent
24
+ calls to e.g. legend do not use it anymore.
26
25
kwargs : dict, optional
27
26
Optional arguments passed to ax.text
28
27
"""
@@ -40,8 +39,9 @@ def labelLine(line, x, label=None, align=True, drop_label=False, **kwargs):
40
39
xa = min (xdata )
41
40
xb = max (xdata )
42
41
else :
43
- for i , (xa , xb ) in enumerate (zip (xdata [:- 1 ], xdata [1 :])):
42
+ for imatch , (xa , xb ) in enumerate (zip (xdata [:- 1 ], xdata [1 :])):
44
43
if min (xa , xb ) <= x <= max (xa , xb ):
44
+ i = imatch
45
45
break
46
46
else :
47
47
raise Exception ("x label location is outside data range!" )
@@ -126,8 +126,8 @@ def labelLines(
126
126
The location of the labels. If a tuple, the labels will be
127
127
evenly spaced between xfirst and xlast (in the axis units).
128
128
drop_label : bool, optional
129
- If True, the label is consumed by the function so that subsequent calls to e.g. legend
130
- do not use it anymore.
129
+ If True, the label is consumed by the function so that subsequent
130
+ calls to e.g. legend do not use it anymore.
131
131
shrink_factor : double, optional
132
132
Relative distance from the edges to place closest labels. Defaults to 0.05.
133
133
kwargs : dict, optional
0 commit comments