Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added left,right,top_corner_label methods #42

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions ternary/ternary_axes_subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@ def left_axis_label(self, label, position=None, rotation=60, offset=0.08,
position = (-offset, 3./5, 2./5)
self._labels["left"] = (label, position, rotation, kwargs)

def right_corner_label(self, label, position=None, rotation=0, offset=0.08,
**kwargs):
"""
Sets the label on the right corner (complements left axis).

Parameters
----------
ax: Matplotlib AxesSubplot, None
The subplot to draw on.
label: String
The axis label
position: 3-Tuple of floats, None
The position of the text label
rotation: float, 0
The angle of rotation of the label
offset: float,
Used to compute the distance of the label from the axis
kwargs:
Any kwargs to pass through to matplotlib.
"""

if not position:
position = (1, offset, 0)
self._labels["left"] = (label, position, rotation, kwargs)

def right_axis_label(self, label, position=None, rotation=-60, offset=0.08,
**kwargs):
"""
Expand All @@ -162,6 +187,31 @@ def right_axis_label(self, label, position=None, rotation=-60, offset=0.08,
position = (2./5 + offset, 3./5, 0)
self._labels["right"] = (label, position, rotation, kwargs)

def left_corner_label(self, label, position=None, rotation=-0, offset=0.08,
**kwargs):
"""
Sets the label on the left corner (complements right axis.)

Parameters
----------
ax: Matplotlib AxesSubplot, None
The subplot to draw on.
label: String
The axis label
position: 3-Tuple of floats, None
The position of the text label
rotation: float, 0
The angle of rotation of the label
offset: float,
Used to compute the distance of the label from the axis
kwargs:
Any kwargs to pass through to matplotlib.
"""

if not position:
position = (-offset, offset, -offset/2)
self._labels["right"] = (label, position, rotation, kwargs)

def bottom_axis_label(self, label, position=None, rotation=0, offset=0.02,
**kwargs):
"""
Expand All @@ -187,6 +237,31 @@ def bottom_axis_label(self, label, position=None, rotation=0, offset=0.02,
position = (1./2, offset, 1./2)
self._labels["bottom"] = (label, position, rotation, kwargs)

def top_corner_label(self, label, position=None, rotation=0, offset=0.2,
**kwargs):
"""
Sets the label on the bottom axis.

Parameters
----------
ax: Matplotlib AxesSubplot, None
The subplot to draw on.
label: String
The axis label
position: 3-Tuple of floats, None
The position of the text label
rotation: float, 0
The angle of rotation of the label
offset: float,
Used to compute the distance of the label from the axis
kwargs:
Any kwargs to pass through to matplotlib.
"""

if not position:
position = (-offset/2,1+offset,0)
self._labels["bottom"] = (label, position, rotation, kwargs)

def annotate(self, text, position, **kwargs):
ax = self.get_axes()
p = project_point(position)
Expand Down