Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Initial commit on adding color support to scatter-plot
This adds a basic version of color support where the color is given as
the third column of the csv file
  • Loading branch information
GregoryAshton committed Oct 7, 2015
commit 7c4c5664f862c25918679511773af0131b115781
12 changes: 9 additions & 3 deletions bashplotlib/scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
if isinstance(f, str):
f = open(f)

data = [tuple(map(float, line.strip().split(','))) for line in f]
xs = [i[0] for i in data]
ys = [i[1] for i in data]
data = [tuple(line.strip().split(',')) for line in f]
xs = [float(i[0]) for i in data]
ys = [float(i[1]) for i in data]
if len(data[0]) > 2:
cs = [i[2].strip() for i in data]
else:
cs = None
else:
xs = [float(str(row).strip()) for row in open(xs)]
ys = [float(str(row).strip()) for row in open(ys)]
Expand All @@ -67,6 +71,8 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
if xp <= x and yp >= y and (xp, yp) not in plotted:
point = pch
plotted.add((xp, yp))
if cs:
colour = cs[i]
printcolour(point, True, colour)
print(" |")
print("-" * (2 * len(get_scale(xs, False, size)) + 2))
Expand Down