Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replacing existing markers with Marker.

  • Loading branch information...
commit 1301f77786726ac1299c8853091f8f96d746d54e 1 parent 3318056
Alex Rasmussen authored
Showing with 106 additions and 11 deletions.
  1. +17 −4 Label.py
  2. +29 −2 Line.py
  3. +4 −1 Marker.py
  4. +28 −2 Scatter.py
  5. +28 −2 VLine.py
21 Label.py
View
@@ -1,23 +1,36 @@
import pylab
from matplotlib import pyplot
from PlotInfo import PlotInfo
+from Marker import Marker
class Label(PlotInfo):
def __init__(self, x, y, text=None, bbox=None):
PlotInfo.__init__(self, "label")
-
+
self.x = x
self.y = y
self.text = text
self.textX = x
self.textY = y
self.arrow = None
- self.marker = None
+ self._marker = Marker()
self.rotation = None
if bbox: self.bbox = dict(bbox)
else: self.bbox = None
+ @property
+ def marker(self):
+ return self._marker.marker
+
+ @marker.setter
+ def marker(self, value):
+ self._marker.marker = value
+
+ @marker.getter
+ def marker(self):
+ return self._marker.marker
+
def setTextOffset(self, x, y):
self.textX = self.x + x
self.textY = self.y + y
@@ -28,7 +41,7 @@ def setTextPosition(self, x, y):
def hasArrow(self, style="->", color="black"):
self.arrow = dict(facecolor=color, arrowstyle=style)
-
+
def draw(self, axis):
kwdict = {}
kwdict["xytext"] = (self.textX, self.textY)
@@ -49,7 +62,7 @@ def draw(self, axis):
labels.append(None)
if self.marker is not None:
- handles.append(axis.scatter([self.x],[self.y],marker=self.marker,
+ handles.append(axis.scatter([self.x],[self.y],marker=self.marker,
color="black"))
labels.append(None)
31 Line.py
View
@@ -3,6 +3,7 @@
from PlotInfo import PlotInfo
from StepType import StepType
import warnings
+from Marker import Marker
class Line(PlotInfo):
steps = StepType("steps")
@@ -22,8 +23,10 @@ def __init__(self,
):
super(Line,self).__init__("line", **kwargs)
- self.marker = marker
- self.markerSize = markerSize
+ self._marker = Marker()
+ self._marker.marker = marker
+ self._marker.size = markerSize
+
# TODO Change to width
self.lineWidth = width
self.color = color
@@ -35,6 +38,30 @@ def __init__(self,
self.alpha = alpha
self.antialiased = antialiased
+ @property
+ def marker(self):
+ return self._marker.marker
+
+ @marker.setter
+ def marker(self, value):
+ self._marker.marker = value
+
+ @marker.getter
+ def marker(self):
+ return self._marker.marker
+
+ @property
+ def markerSize(self):
+ return self._marker.size
+
+ @markerSize.setter
+ def markerSize(self, value):
+ self._marker.size = value
+
+ @markerSize.getter
+ def markerSize(self):
+ return self._marker.size
+
def stepFunction(self, stepType="pre"):
self.steps = stepType
5 Marker.py
View
@@ -6,7 +6,7 @@ class Marker(object):
descriptions. Either can be used when specifying marker type.
"""
_MARK_TRANSLATOR = {
- "" : ["none"],
+ "" : ["none", None],
"." : ["point", "points"],
"," : ["pixel", "pixels"],
"o" : ["circle", "circles"],
@@ -55,3 +55,6 @@ def marker(self, value):
self._marker = Marker.VALID_MARKS[value]
+ @marker.getter
+ def marker(self):
+ return self._marker
30 Scatter.py
View
@@ -1,6 +1,7 @@
import pylab
from matplotlib import pyplot
from PlotInfo import *
+from Marker import Marker
class Scatter(PlotInfo):
def __init__(self,
@@ -8,10 +9,35 @@ def __init__(self,
markerSize=20,
color="black", **kwargs):
super(Scatter,self).__init__("scatter", **kwargs)
- self.marker = marker
- self.markerSize = markerSize
+ self._marker = Marker()
+ self._marker.marker = marker
+ self._marker.size = markerSize
self.color = color
+ @property
+ def marker(self):
+ return self._marker.marker
+
+ @marker.setter
+ def marker(self, value):
+ self._marker.marker = value
+
+ @marker.getter
+ def marker(self):
+ return self._marker.marker
+
+ @property
+ def markerSize(self):
+ return self._marker.size
+
+ @markerSize.setter
+ def markerSize(self, value):
+ self._marker.size = value
+
+ @markerSize.getter
+ def markerSize(self):
+ return self._marker.size
+
def draw(self, axis):
kwdict = {}
kwdict["marker"] = self.marker
30 VLine.py
View
@@ -1,6 +1,7 @@
import pylab
from matplotlib import pyplot
from PlotInfo import PlotInfo
+from Marker import Marker
class VLine(PlotInfo):
def __init__(self,
@@ -13,13 +14,38 @@ def __init__(self,
**kwargs):
super(VLine,self).__init__("vline", **kwargs)
- self.marker = marker
- self.markerSize = markerSize
+ self._marker = Marker()
+ self._marker.marker = marker
+ self._marker.size = markerSize
self.width = width
self.color = color
self.lineStyle = lineStyle
self.dates = dates
+ @property
+ def marker(self):
+ return self._marker.marker
+
+ @marker.setter
+ def marker(self, value):
+ self._marker.marker = value
+
+ @marker.getter
+ def marker(self):
+ return self._marker.marker
+
+ @property
+ def markerSize(self):
+ return self._marker.size
+
+ @markerSize.setter
+ def markerSize(self, value):
+ self._marker.size = value
+
+ @markerSize.getter
+ def markerSize(self):
+ return self._marker.size
+
def draw(self, axis):
# Present to keep the PlotInfo sorting from failing
self.yValues = [0 for x in self.xValues]
Please sign in to comment.
Something went wrong with that request. Please try again.