-
Notifications
You must be signed in to change notification settings - Fork 4
/
Marker.py
62 lines (51 loc) · 1.8 KB
/
Marker.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
class Marker(object):
"""
This property controls the way that a plot element's markers look.
"""
_MARK_TRANSLATOR = {
"" : ["none", None],
"." : ["point", "points"],
"," : ["pixel", "pixels"],
"o" : ["circle", "circles"],
"v" : ["down triangle", "down triangles"],
"^" : ["up triangle", "up triangles"],
"<" : ["left triangle", "left triangles"],
">" : ["right triangle", "right triangles"],
"s" : ["square", "squares"],
"p" : ["pentagon", "pentagons"],
"*" : ["star", "stars"],
"h" : ["hexagon", "hexagons", "vertical hexagon", "vertical hexagons"],
"H" : ["horizontal hexagon", "horizontal hexagons"],
"+" : ["plus", "pluses", "plusses"],
"x" : ["x", "cross", "crosses"],
"D" : ["diamond", "diamonds"],
"d" : ["thin diamond", "thin diamonds"],
"|" : ["vline", "vlines", "vertical line", "vertical lines"],
"_" : ["hline", "hlines", "horizontal line", "horizontal lines"]
}
"""
This dictionary (derived from _MARK_TRANSLATOR) maps valid marker types to
their matplotlib equivalents.
"""
VALID_MARKS = {}
for (glyph, equivalents) in _MARK_TRANSLATOR.items():
VALID_MARKS[glyph] = glyph
for equiv in equivalents:
VALID_MARKS[equiv] = glyph
def __init__(self):
self._marker = None
self.size = 8.0
"""
The size of the marker
"""
@property
def marker(self):
"""
Defines the shape of the marker.
"""
return self._marker
@marker.setter
def marker(self, value):
if value not in Marker.VALID_MARKS:
raise ValueError("'%s' is not a valid mark" % (value))
self._marker = Marker.VALID_MARKS[value]