-
Notifications
You must be signed in to change notification settings - Fork 4
/
HLine.py
92 lines (74 loc) · 2.39 KB
/
HLine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import itertools
from matplotlib import pyplot
from PlotInfo import PlotInfo
from Marker import Marker
from LineStyle import LineStyle
class HLine(PlotInfo):
"""
A plot element that represents a horizontal line that passes through a
given point on the y-axis.
"""
def __init__(self,
marker = None,
markerSize = 8.0,
width = 1.0,
color = 'black',
lineStyle = '-',
dates = False,
**kwargs):
super(HLine,self).__init__("hline", **kwargs)
self._marker = Marker()
self._marker.marker = marker
self._marker.size = markerSize
self.width = width
"""
The line's width
"""
self.color = color
"""
The line's color. See :ref:`styling-colors` for valid colors.
"""
self._lineStyle = LineStyle()
self._lineStyle.style = lineStyle
self.dates = dates
@property
def lineStyle(self):
"""
The line style for this line; see :ref:`styling-lines` for more
information about available line styles.
"""
return self._lineStyle.style
@lineStyle.setter
def lineStyle(self, value):
self._lineStyle.style = value
@property
def marker(self):
"""
The marker used to mark points on the line. See :ref:`styling-markers`
for more information about available markers.
"""
return self._marker.marker
@marker.setter
def marker(self, value):
self._marker.marker = value
@property
def markerSize(self):
"""
The size of this line's markers.
"""
return self._marker.size
@markerSize.setter
def markerSize(self, value):
self._marker.size = value
def draw(self, fig, axis, transform=None):
# Present to keep the PlotInfo sorting from failing
self.xValues = list(itertools.repeat(0, len(self.yValues)))
PlotInfo.draw(self, fig, axis, transform)
kwdict = self.getAttributes()
kwdict["linestyle"] = self.lineStyle
kwdict["color"] = self.color
kwdict["label"] = self.label
kwdict["linewidth"] = self.width
return [[axis.axhline(y=yValue, **kwdict)
for yValue in self.yValues],
[self.label for yValue in self.yValues]]