def add_ticks(da, locations, direction):
segments = [None] * (len(locations)*2)
if direction == 'vertical':
x1, x2, x3, x4 = np.array([0.0, 1/5, 4/5, 1.0]) * da.width
for i, y in enumerate(locations):
segments[i*2:i*2+2] = [((x1, y), (x2, y)),
((x3, y), (x4, y))]
else:
y1, y2, y3, y4 = np.array([0.0, 1/5, 4/5, 1.0]) * da.height
for i, x in enumerate(locations):
segments[i*2:i*2+2] = [((x, y1), (x, y2)),
((x, y3), (x, y4))]
coll = mcoll.LineCollection(segments,
color='#CCCCCC',
linewidth=1,
antialiased=False)
da.add_artist(coll)
评论列表
文章目录