Created
May 14, 2012 09:47
-
-
Save varrunr/2692992 to your computer and use it in GitHub Desktop.
Sample-matplotlib-plt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import sys | |
def populate(filename,num): | |
x = [] | |
y = [] | |
f = open(filename,"r") | |
contents = f.read() | |
lines = contents.split('\n') | |
lines = lines[0:num] | |
for line in lines: | |
x.append(float(line.split()[0])) | |
y.append(float(line.split()[1])) | |
return x,y | |
def main(): | |
sz = int(sys.argv[3]) | |
filename = sys.argv[1] | |
filename2 = sys.argv[2] | |
x , y = populate(filename,sz) | |
m , n = populate(filename2,sz) | |
plt.plot( x, y, color='r', label="cpu") | |
plt.plot( m, n, color='b', label="gpu") | |
plt.title(" Quick Sort CPU vs GPU") | |
plt.xlabel("Number of Bases") | |
plt.ylabel("Running Time(s)") | |
leg = plt.legend(loc=2,ncol=2,shadow=True) | |
frame = leg.get_frame() | |
frame.set_facecolor('0.80') | |
for t in leg.get_texts(): | |
t.set_fontsize('small') | |
for l in leg.get_lines(): | |
l.set_linewidth(1.5) | |
plt.savefig("qsort-cpu-vs-gpu.png") | |
plt.show() | |
if __name__ == '__main__': main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment