-
Notifications
You must be signed in to change notification settings - Fork 4
/
Grid.py
53 lines (44 loc) · 1.5 KB
/
Grid.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
from boomslang.LineStyle import LineStyle
class Grid(object):
"""
The Grid plot element defines a set of gridlines that are displayed behind
all other plot elements
"""
def __init__(self, color="#dddddd", style="-", width=0.5, visible=True):
self.color = color
"""
The color of the gridlines; see :ref:`styling-colors` for more
information on available colors.
"""
self.lineWidth = width
"""
The width of gridlines.
"""
self._lineStyle = LineStyle()
self._lineStyle.style = style
self.visible = visible
"""
If True, the grid's lines are visible. If False, they are invisible.
"""
self.which = 'major'
"""
If "major", the plot's major ticks have grid lines. If "minor", the
plot's minor ticks have grid lines. If "both", both major and minor
ticks have grid lines.
"""
@property
def style(self):
"""
The style of the grid's lines; see :ref:`styling-lines` for more
information about available line styles.
"""
return self._lineStyle.style
@style.setter
def style(self, value):
self._lineStyle.style = value
def draw(self, fig, axes):
if self.visible:
axes.grid(color=self.color, linestyle=self.style,
which=self.which, linewidth=self.lineWidth)
# Gridlines should be below plots
axes.set_axisbelow(True)