implement plotting function on log scale #9
|
@ -1,11 +1,16 @@
|
|||
import os
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import pdb
|
||||
import glob
|
||||
|
||||
# IO: This loads the timings for you
|
||||
threads, timings = [], []
|
||||
for file in os.listdir('timings'):
|
||||
files = os.listdir('timings')
|
||||
files.sort(key= lambda x: int(x.split('_')[0]))
|
||||
for file in files:
|
||||
with open(f'timings/{file}', 'r') as f:
|
||||
if 'None' not in file:
|
||||
n, t = f.read().strip().split(',')
|
||||
threads.append(int(n))
|
||||
timings.append(float(t))
|
||||
|
@ -17,7 +22,13 @@ print('This is the data I loaded: threads =', threads, ', timings =',timings)
|
|||
fig, axs = plt.subplots()
|
||||
|
||||
# CREATE YOUR PLOT HERE
|
||||
plt.plot(threads, timings, '.--')
|
||||
plt.xlabel('Threads')
|
||||
plt.ylabel('Timings')
|
||||
plt.xscale('log')
|
||||
|
||||
# Remember to label your axis
|
||||
# Feel free to make it pretty
|
||||
|
||||
|
||||
plt.savefig('threads_v_timings.png', dpi=300)
|
||||
|
|
BIN
exercises/exerciseA/threads_v_timings.png
Normal file
BIN
exercises/exerciseA/threads_v_timings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
Loading…
Reference in a new issue