Skip to content

Commit 29145d7

Browse files
committed
Added code for displaying the 0-axes
1 parent 85bc5c7 commit 29145d7

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

bashplotlib/scatterplot.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def get_scale(series, is_y=False, steps=20):
3434
def _plot_scatter(xs, ys, size, pch, colour, title, title_align, cs, xtitle, ytitle):
3535
plotted = set()
3636
width = len(get_scale(xs, False, size))
37+
xscale = get_scale(xs,False,size)
3738

3839
if title:
3940
print(box_text(title, title_align, 2 * (width + 1)))
@@ -42,17 +43,32 @@ def _plot_scatter(xs, ys, size, pch, colour, title, title_align, cs, xtitle, yti
4243
print("y: " + ytitle)
4344

4445
print("-" * (2 * (width + 2)))
45-
for y in get_scale(ys, True, size):
46+
for y in get_scale(ys, True, size): #y axis loop
4647
print("|", end=' ')
47-
for x in get_scale(xs, False, size):
48+
49+
for x in get_scale(xs, False, size): #x axis loop
4850
point = " "
4951
for (i, (xp, yp)) in enumerate(zip(xs, ys)):
5052
if xp <= x and yp >= y and (xp, yp) not in plotted:
5153
point = pch
52-
plotted.add((xp, yp))
54+
plotted.add((xp, yp)) # add the point on the graph
5355
if cs:
5456
colour = cs[i]
55-
printcolour(point + " ", True, colour)
57+
#printcolour(point + " ", True, colour)
58+
59+
if point == pch:
60+
printcolour(point + " ", True, colour)
61+
else:
62+
if x == 0 and y == 0:
63+
printcolour("o ", True, colour)
64+
elif y == 0:
65+
printcolour("- ", True, colour)
66+
elif x == 0:
67+
printcolour("| ", True, colour)
68+
else:
69+
printcolour(point + " ", True, colour)
70+
71+
5672
print(" |")
5773
print("-" * (2 * (width + 2)))
5874

0 commit comments

Comments
 (0)