Skip to content

Commit

Permalink
Updating scatterplot scripts to handle larger scales
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed May 19, 2021
1 parent 7a7c8ce commit 36b00f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
24 changes: 11 additions & 13 deletions src/scripts/counter_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@

def shorten_name(name):
tmp = name
# remove arguments in function name, if they exist
leftparen = tmp.find('(')
rightparen = tmp.rfind(')')
if leftparen > 0 and rightparen > 0:
tokens1 = tmp.split('(')
tokens2 = tmp.split(')')
tmp = tokens1[0] + '()' + tokens2[len(tokens2)-1]
# otherwise, just take the first 64 characters.
short = (tmp[:77] + '...') if len(tmp) > 77 else tmp
return short.replace('_', '$\_$')
Expand All @@ -34,21 +27,23 @@ def shorten_name(name):
index = index + 1
if len(row) == 3 and not row[0].strip().startswith("#"):
try:
mytup = (float(row[0]),float(row[1]))
mytup = (float(row[0])/1000000000.0,float(row[1]))
except ValueError as e:
print(index, " Bad row: ", row)
continue
if row[2] not in dictionary:
dictionary[row[2]] = [mytup]
else:
dictionary[row[2]].append(mytup)
if (index % 100000 == 0):
print (index, 'rows parsed...', end='\r', flush=True)
print ("Parsed", index, "samples")

#resize the figure
# Get current size
fig_size = pl.rcParams["figure.figsize"]
# Set figure width to 12 and height to 9
fig_size[0] = 8
fig_size[0] = 16
fig_size[1] = 4
pl.rcParams["figure.figsize"] = fig_size

Expand All @@ -65,9 +60,12 @@ def shorten_name(name):
values = np.array([x[1] for x in dictionary[key]])
name = shorten_name(key)
pl.title(name);
#pl.semilogy(timestamps, values, color=mycolor[index-1], marker=mymark[index-1], linestyle=' ', label=name)
#pl.plot(timestamps, values, color=mycolor[index-1], marker=mymark[index-1], linestyle=' ', label=name)
pl.plot(timestamps, values, marker='o', color='blue')
marker = '1'
extension = '.pdf'
if len(timestamps) > 1000000:
marker = ','
extension = '.png'
pl.plot(timestamps, values, marker=marker, color='blue', linestyle=' ', label=name)
pl.draw()
axes.set_autoscale_on(True) # enable autoscale
axes.autoscale_view(True,True,True)
Expand All @@ -78,5 +76,5 @@ def shorten_name(name):
pl.tight_layout()
name = name.replace(" ", "_")
name = ''.join([c for c in name if c in safechars])
pl.savefig(name+".png")
pl.savefig(name+extension)
pl.close()
15 changes: 9 additions & 6 deletions src/scripts/task_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,28 @@ def shorten_name(name):
# Get current size
fig_size = pl.rcParams["figure.figsize"]
# Set figure width to 12 and height to 9
fig_size[0] = 12
fig_size[1] = 9
fig_size[0] = 16
fig_size[1] = 10
pl.rcParams["figure.figsize"] = fig_size

mymark = ('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd')
mycolor = ('blue', 'green', 'red', 'cyan', 'magenta', 'yellow', 'black', 'darkblue', 'darkgreen', 'darkred')
mycolor = ('blue', 'green', 'red', 'royalblue', 'darkmagenta', 'darkslategrey', 'black', 'darkblue', 'darkgreen', 'darkred')
#mycolor = iter([pl.cm.Dark2(i) for i in range(8)])

index = 0
numplots = min(len(dictionary), 10)
for key in sorted(dictionary, key=lambda key: len(dictionary[key]), reverse=True):
index = index + 1
print ("Plotting", key)
axes = pl.subplot(((numplots+1)/2), 2, index)
timestamps = np.array([x[0] for x in dictionary[key]])
values = np.array([x[1] for x in dictionary[key]])
timestamps = np.array([x[0]/1000000000 for x in dictionary[key]])
values = np.array([x[1]/1000 for x in dictionary[key]])
name = shorten_name(key)
axes.set_title(name);
pl.plot(timestamps, values, color=mycolor[index-1], marker='.', linestyle=' ', label=name)
#pl.plot(timestamps, values, color=mycolor[next(mycolor)], marker='.', linestyle=' ', label=name)
#pl.plot(timestamps, values, color=mycolor[index-1], marker=mymark[index-1], linestyle=' ', label=name)
pl.semilogy(timestamps, values, color=mycolor[index-1], marker=mymark[index-1], linestyle=' ', label=name)
#pl.semilogy(timestamps, values, color=mycolor[index-1], marker=mymark[index-1], linestyle=' ', label=name)
pl.draw()
axes.set_autoscale_on(True) # enable autoscale
axes.autoscale_view(True,True,True)
Expand Down

0 comments on commit 36b00f6

Please sign in to comment.