Duplicated code remove (#1780)

* print function to console.print

* remove duplicated and worng positioned class

* black formatter apply

* circular import resolve

* add pylint import-outside-toplevel disable

Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
This commit is contained in:
Minha, Jeong
2022-05-08 02:53:52 +09:00
committed by GitHub
parent 9fca640d8e
commit e00534c9d1
2 changed files with 7 additions and 45 deletions

View File

@@ -17,15 +17,20 @@ class LineAnnotateDrawer:
def __init__(self, ax: matplotlib.axes = None):
self.ax = ax
# pylint: disable=import-outside-toplevel
def draw_lines_and_annotate(self):
"""Draw lines."""
print("Click twice for annotation.\nClose window to keep using terminal.\n")
from openbb_terminal.rich_config import console
console.print(
"Click twice for annotation.\nClose window to keep using terminal.\n"
)
while True:
xy = plt.ginput(2)
# Check whether the user has closed the window or not
if not plt.get_fignums():
print("")
console.print("")
return
if len(xy) == 2:

View File

@@ -1318,49 +1318,6 @@ def get_rf() -> float:
return 0.02
class LineAnnotateDrawer:
"""Line drawing class."""
def __init__(self, ax: matplotlib.axes = None):
self.ax = ax
def draw_lines_and_annotate(self):
# ymin, _ = self.ax.get_ylim()
# xmin, _ = self.ax.get_xlim()
# self.ax.plot(
# [xmin, xmin],
# [ymin, ymin],
# lw=0,
# color="white",
# label="X - leave interactive mode\nClick twice for annotation",
# )
# self.ax.legend(handlelength=0, handletextpad=0, fancybox=True, loc=2)
# self.ax.figure.canvas.draw()
"""Draw lines."""
console.print(
"Click twice for annotation.\nClose window to keep using terminal.\n"
)
while True:
xy = plt.ginput(2)
# Check whether the user has closed the window or not
if not plt.get_fignums():
console.print("")
return
if len(xy) == 2:
x = [p[0] for p in xy]
y = [p[1] for p in xy]
if (x[0] == x[1]) and (y[0] == y[1]):
txt = input("Annotation: ")
self.ax.annotate(txt, (x[0], y[1]), ha="center", va="center")
else:
self.ax.plot(x, y)
self.ax.figure.canvas.draw()
def system_clear():
"""Clear screen"""
os.system("cls||clear") # nosec