Skip to content

Commit d253b8e

Browse files
author
Yosi Angel
committed
task 1
1 parent cded03a commit d253b8e

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

bashplotlib/scatterplot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs):
3434
if title:
3535
print(box_text(title, 2 * (len(get_scale(xs, False, size)) + 1)))
3636

37-
print("-" * (2 * (len(get_scale(xs, False, size)) + 2)))
37+
# print("-" * (2 * (len(get_scale(xs, False, size)) + 2)))
3838
for y in get_scale(ys, True, size):
3939
print("|", end=' ')
4040
for x in get_scale(xs, False, size):
@@ -47,7 +47,8 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs):
4747
colour = cs[i]
4848
printcolour(point + " ", True, colour)
4949
print(" |")
50-
print("-" * (2 * (len(get_scale(xs, False, size)) + 2)))
50+
# print("-" * (2 * (len(get_scale(xs, False, size)) + 2)))
51+
print(wrap_text_with_symbol("-" * (2 * (len(get_scale(xs, False, size)) + 1)), "+"))
5152

5253
def plot_scatter(f, xs, ys, size, pch, colour, title):
5354
"""

bashplotlib/utils/helpers.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ def box_text(text, width, offset=0):
8080
"""
8181
Return text inside an ascii textbox
8282
"""
83-
box = " " * offset + "-" * (width+2) + "\n"
83+
box = " " * offset + wrap_text_with_symbol("-" * width, "+") + "\n"
84+
# box = " " * offset + "-" * (width+2) + "\n"
8485
box += " " * offset + "|" + text.center(width) + "|" + "\n"
85-
box += " " * offset + "-" * (width+2)
86+
# box += " " * offset + "-" * (width+2)
87+
box += " " * offset + wrap_text_with_symbol("-" * width, "+")
8688
return box
89+
90+
def wrap_text_with_symbol(text, symbol = "+"):
91+
"""
92+
Returns text wrapped with symbol
93+
default wrapper is '+'
94+
"""
95+
newText = symbol + text + symbol
96+
return newText

scratch.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# scratch.py
2+
from bashplotlib.scatterplot import plot_scatter
3+
4+
x_coords = [-10,20,30]
5+
y_coords = [-10,20,30]
6+
width = 10
7+
char = 'x'
8+
color = 'default'
9+
title = 'My Test Graph'
10+
11+
plot_scatter(
12+
None,
13+
x_coords,
14+
y_coords,
15+
width,
16+
char,
17+
color,
18+
title)

0 commit comments

Comments
 (0)