summaryrefslogtreecommitdiffstats
path: root/plot.py
diff options
context:
space:
mode:
Diffstat (limited to 'plot.py')
-rwxr-xr-xplot.py76
1 files changed, 57 insertions, 19 deletions
diff --git a/plot.py b/plot.py
index 1534bc4..4eab800 100755
--- a/plot.py
+++ b/plot.py
@@ -4,52 +4,90 @@ import math
import os
import sys
+import matplotlib
from matplotlib import pyplot
from matplotlib.pyplot import *
+matplotlib.rc('text', **{
+ 'usetex': True})
+matplotlib.rc('font', **{
+ 'family': 'serif',
+ 'serif': 'Times',
+ 'sans-serif': 'Helvetica',
+ 'monospace': 'Courier'})
+
pyplot.subplots_adjust(wspace=0.2, hspace=0.2)
-n_plots = len(sys.argv) - 1
+class SensibleScalarFormatter(matplotlib.ticker.ScalarFormatter):
+ "ScalarFormatter which rounds order of magnitude to a multiple of 3"
+ def __init__(self):
+ matplotlib.ticker.ScalarFormatter.__init__(self)
+ self.set_powerlimits([-6, 6])
+ self.set_scientific(True)
+
+ def _set_orderOfMagnitude(self, range):
+ # Calculate "best" order in the usual way
+ matplotlib.ticker.ScalarFormatter._set_orderOfMagnitude(self, range)
+
+ # Round down to sensible (millions, billions, etc) order
+ self.orderOfMagnitude = self.orderOfMagnitude - (self.orderOfMagnitude % 3)
+
+ self.set_scientific(True)
+
+n_plots = len(sys.argv) - 2
for i in range(n_plots):
- filename = sys.argv[i+1]
+ filename = sys.argv[i+2]
file = open(filename, 'r')
- header = file.readline()
+ # pyplot.clf()
+
+ ax = pyplot.subplot(math.ceil(math.sqrt(n_plots)),
+ math.ceil(math.sqrt(n_plots)),
+ i + 1)
+
+ ax.xaxis.set_major_formatter(SensibleScalarFormatter())
+ ax.yaxis.set_major_formatter(SensibleScalarFormatter())
+ for a in ['x', 'y']:
+ ax.grid(which='major', axis=a, zorder=1,
+ linewidth=0.5, linestyle=':', color='0', dashes=[0.5, 8.0])
+
+ header = file.readline()
columns = header[1:].split()
- pyplot.subplot(math.ceil(math.sqrt(n_plots)),
- math.ceil(math.sqrt(n_plots)),
- i + 1)
- pyplot.xlabel('# Elements')
+ pyplot.xlabel('Elements')
pyplot.ylabel('Time (s)')
times = []
for i in columns:
times.append([])
- ns = []
- zix_tree_times = []
- zix_sorted_array_times = []
- glib_times = []
for line in file:
if line[0] == '#':
continue;
- #(n, zix_tree, zix_sorted_array, glib) = line.split()
+
fields = line.split()
- num = 0
+ num = 0
for i in fields:
times[num].append([float(i)])
num += 1
- #ns.append(int(n))
- #zix_tree_times.append(float(zix_tree))
- #zix_sorted_array_times.append(float(zix_sorted_array))
- #glib_times.append(float(glib))
file.close()
for i in range(len(times) - 1):
matplotlib.pyplot.plot(times[0], times[i + 1], '-o', label=columns[i + 1])
- pyplot.legend(loc='upper left')
+ pyplot.legend(loc='upper left',
+ handletextpad=0.15, borderpad=0.20, borderaxespad=0,
+ labelspacing=0.10, columnspacing=0,
+ framealpha=0.90)
+
pyplot.title(os.path.splitext(os.path.basename(filename))[0].title())
-matplotlib.pyplot.show()
+ # out = filename.replace('.dat', '.png')
+ # print('Writing %s' % out)
+ # matplotlib.pyplot.savefig(out, bbox_inches='tight', pad_inches=0.025)
+
+print('Writing %s' % sys.argv[1])
+matplotlib.pyplot.tight_layout()
+matplotlib.pyplot.savefig(sys.argv[1])
+
+#matplotlib.pyplot.show()