Skip to content

Commit

Permalink
Fix corner / axis label overwrites and update readme + example notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
marcharper committed Apr 3, 2019
1 parent fb324b0 commit 4aee988
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 36 deletions.
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,38 @@ parallel to the axes with `horizonal_line`, `left_parallel_line`, and

```python
import ternary

scale = 40
figure, tax = ternary.figure(scale=scale)

# Draw Boundary and Gridlines
tax.boundary(linewidth=2.0)
tax.gridlines(color="blue", multiple=5)

# Set Axis labels and Title
fontsize = 20
tax.set_title("Various Lines", fontsize=20)
tax.left_axis_label("Left label $\\alpha^2$", fontsize=fontsize)
tax.right_axis_label("Right label $\\beta^2$", fontsize=fontsize)
tax.bottom_axis_label("Bottom label $\\Gamma - \\Omega$", fontsize=fontsize)

fontsize = 12
offset = 0.14
tax.set_title("Various Lines\n", fontsize=fontsize)
tax.right_corner_label("X", fontsize=fontsize)
tax.top_corner_label("Y", fontsize=fontsize)
tax.left_corner_label("Z", fontsize=fontsize)
tax.left_axis_label("Left label $\\alpha^2$", fontsize=fontsize, offset=offset)
tax.right_axis_label("Right label $\\beta^2$", fontsize=fontsize, offset=offset)
tax.bottom_axis_label("Bottom label $\\Gamma - \\Omega$", fontsize=fontsize, offset=offset)

# Draw lines parallel to the axes
tax.horizontal_line(16)
tax.left_parallel_line(10, linewidth=2., color='red', linestyle="--")
tax.right_parallel_line(20, linewidth=3., color='blue')

# Draw an arbitrary line, ternary will project the points for you
p1 = (12, 8, 20)
p2 = (2, 26, 12)
p1 = (22, 8, 10)
p2 = (2, 22, 16)
tax.line(p1, p2, linewidth=3., marker='s', color='green', linestyle=":")

tax.ticks(axis='lbr', multiple=5, linewidth=1)


tax.ticks(axis='lbr', multiple=5, linewidth=1, offset=0.025)
tax.get_axes().axis('off')
tax.clear_matplotlib_ticks()
tax.show()
```

Expand Down
41 changes: 22 additions & 19 deletions examples/Ternary-Examples.ipynb

Large diffs are not rendered by default.

Binary file modified readme_images/various_lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions ternary/ternary_axes_subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def bottom_axis_label(self, label, position=None, rotation=0, offset=0.02,

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

def right_corner_label(self, label, position=None, rotation=0, offset=0.08,
**kwargs):
Expand All @@ -210,7 +210,7 @@ def right_corner_label(self, label, position=None, rotation=0, offset=0.08,

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

def left_corner_label(self, label, position=None, rotation=0, offset=0.08,
**kwargs):
Expand Down Expand Up @@ -256,7 +256,7 @@ def top_corner_label(self, label, position=None, rotation=0, offset=0.2,

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

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

0 comments on commit 4aee988

Please sign in to comment.