def draw_line(self, pos, horizontal=False, label=None,
color='gray90', label_color='gray35', **_):
"""Draw one horizontal or vertical line with optional color and label"""
if pos is None:
return
if pos < self.zoom_area[0 + horizontal] or pos > self.zoom_area[2 + horizontal]:
return
turtle.penup()
xscale = turtle.getscreen().xscale
yscale = turtle.getscreen().yscale
if label:
font_family, font_size = self.font
turtle.color(label_color)
turtle.setposition(*self.label_pos(pos=pos, label=label, horizontal=horizontal))
turtle.write(label, align='right' if horizontal else'center',
font=(font_family, font_size))
turtle.setposition(-4 / xscale if horizontal else pos,
pos if horizontal else -4 / yscale)
turtle.pendown()
turtle.setposition(1 / xscale if horizontal else pos,
pos if horizontal else 1 / yscale)
turtle.color(color)
turtle.pendown()
turtle.setposition(self.plot_area[2] if horizontal else pos,
pos if horizontal else self.plot_area[3])
turtle.penup()
评论列表
文章目录