diff --git a/ternary/lines.py b/ternary/lines.py index baa123b..a7708ad 100644 --- a/ternary/lines.py +++ b/ternary/lines.py @@ -278,20 +278,23 @@ def ticks(ax, scale, ticks=None, locations=None, multiple=1, axis='b', if clockwise: # Right parallel loc2 = (scale - i, i + offset, 0) - text_location = (scale - i, i + 2 * offset, 0) + text_location = (scale - i, i + 1.5 * offset, 0) tick = ticks[-(index+1)] + valign = "baseline" else: # Horizontal loc2 = (scale - i + offset, i, 0) - text_location = (scale - i + 2.6 * offset, i - 0.5 * offset, 0) + text_location = (scale - i + 1.5 * offset, i, 0) tick = ticks[index] + valign = "center" line(ax, loc1, loc2, color=axes_colors['r'], **kwargs) x, y = project_point(text_location) if isinstance(tick, str): s = tick else: s = tick_formats['r'] % tick - ax.text(x, y, s, horizontalalignment="center", + ax.text(x, y, s, + horizontalalignment="left", verticalalignment=valign, color=axes_colors['r'], fontsize=fontsize) if 'l' in axis: @@ -300,20 +303,23 @@ def ticks(ax, scale, ticks=None, locations=None, multiple=1, axis='b', if clockwise: # Horizontal loc2 = (-offset, i, 0) - text_location = (-2 * offset, i - 0.5 * offset, 0) + text_location = (- 1.5 * offset, i, 0) tick = ticks[index] + valign = "center" else: # Right parallel loc2 = (-offset, i + offset, 0) - text_location = (-2 * offset, i + 1.5 * offset, 0) + text_location = (-1.5 * offset, i + 1.5 * offset, 0) tick = ticks[-(index+1)] + valign = "baseline" line(ax, loc1, loc2, color=axes_colors['l'], **kwargs) x, y = project_point(text_location) if isinstance(tick, str): s = tick else: s = tick_formats['l'] % tick - ax.text(x, y, s, horizontalalignment="center", + ax.text(x, y, s, + horizontalalignment="right", verticalalignment=valign, color=axes_colors['l'], fontsize=fontsize) if 'b' in axis: @@ -322,12 +328,12 @@ def ticks(ax, scale, ticks=None, locations=None, multiple=1, axis='b', if clockwise: # Right parallel loc2 = (i + offset, -offset, 0) - text_location = (i + 3 * offset, -3.5 * offset, 0) + text_location = (i + 1.5 * offset, -1.5 * offset, 0) tick = ticks[-(index+1)] else: # Left parallel loc2 = (i, -offset, 0) - text_location = (i + 0.5 * offset, -3.5 * offset, 0) + text_location = (i, -1.5 * offset, 0) tick = ticks[index] line(ax, loc1, loc2, color=axes_colors['b'], **kwargs) x, y = project_point(text_location) @@ -335,5 +341,6 @@ def ticks(ax, scale, ticks=None, locations=None, multiple=1, axis='b', s = tick else: s = tick_formats['b'] % tick - ax.text(x, y, s, horizontalalignment="center", + ax.text(x, y, s, + horizontalalignment="center", verticalalignment="top", color=axes_colors['b'], fontsize=fontsize)