This is more or less what you want:
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
def plot_ticks(start, stop, tick, n):
r = np.linspace(0, 1, n+1)
x = start[0] * (1 - r) + stop[0] * r
x = np.vstack((x, x + tick[0]))
y = start[1] * (1 - r) + stop[1] * r
y = np.vstack((y, y + tick[1]))
plt.plot(x, y, 'k', lw=1)
n = 10
tick_size = 0.2
margin = 0.05
left = np.r_[0, 0]
right = np.r_[1, 0]
top = np.r_[0.5, 3**0.5 / 2]
triangle = np.c_[left, right, top, left]
bottom_tick = tick_size * (right - top) / n
right_tick = tick_size * (top - left) / n
left_tick = tick_size * (left - right) / n
plt.plot(triangle[0], triangle[1], 'k', lw=2)
plot_ticks(left, right, bottom_tick, n)
plot_ticks(right, top, right_tick, n)
plot_ticks(left, top, left_tick, n)
plt.axis([left[0]-margin, right[0]+margin, left[1]-margin, top[1]+margin])
plt.gca().set_aspect('equal', adjustable='box')
plt.show()
Result:

source
share