def add_arrow(line: Line2D, position=None, size=15, color=None): """ add an arrow to a line. line: Line2D object position: x-position of the arrow. If None, mean of xdata is taken size: size of the arrow in fontsize points color: if None, line color is taken. """ if color is None: color = line.get_color() alpha = line.get_alpha() x_data = line.get_xdata() y_data = line.get_ydata() if position is None: position = x_data.mean() # find closest index start_ind = np.argmin(np.absolute(x_data - position)) end_ind = start_ind + 1 line.axes.annotate('', xytext=(x_data[start_ind], y_data[start_ind]), xy=(x_data[end_ind], y_data[end_ind]), arrowprops=dict(arrowstyle="-|>", color=color, alpha=alpha), size=size)
def ponto_2d(self, ponto: Line2D): self.__ponto_2d = ponto if(ponto): temp_alpha = ponto.get_alpha() self.__alpha_pt = temp_alpha if temp_alpha else self.__alpha_incremento