Skip to content

Commit

Permalink
Merge pull request #23 from sivasankariit/master
Browse files Browse the repository at this point in the history
Added 'LabelProperty' to 'Label' plot element. Closes #13.
  • Loading branch information
alexras committed Nov 8, 2012
2 parents aae276b + 89b3dd6 commit 9e9ee15
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Label.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from matplotlib import pyplot
from PlotInfo import PlotInfo
from Marker import Marker
from LabelProperties import LabelProperties

class Label(PlotInfo):
"""
Expand Down Expand Up @@ -33,7 +34,7 @@ def __init__(self, x, y, text=None, bbox=None):

self._marker = Marker()

self.rotation = None
self._labelProperties = LabelProperties()

if bbox:
self.bbox = dict(bbox)
Expand Down Expand Up @@ -84,6 +85,27 @@ def setTextPosition(self, x, y):
self.textX = x
self.textY = y

@property
def labelProperties(self):
"""
A dictionary of properties that control the appearance of the label. See
:ref:`styling-labels` for more information on which properties can be
set.
"""
return self._labelProperties

@labelProperties.setter
def labelProperties(self, propsobj):
self.labelProperties.update(propsobj)

@property
def rotation(self):
return self._labelProperties["rotation"]

@rotation.setter
def rotation(self, value):
self._labelProperties["rotation"] = value

def hasArrow(self, style="->", color="black"):
"""
Defines an arrow between the label's text and its point. Valid arrow
Expand All @@ -99,7 +121,7 @@ def draw(self, fig, axis, transform=None):
kwdict["textcoords"] = "data"
kwdict["arrowprops"] = self.arrow
kwdict["horizontalalignment"] = "center"
kwdict["rotation"] = self.rotation
kwdict.update(self.labelProperties)

# For props, see
# http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.patches.Rectangle
Expand Down

0 comments on commit 9e9ee15

Please sign in to comment.