add code for best plot eva #2

Open
alessiase wants to merge 1 commit from alessiase/2024-heraklion-parallel-python:best_plot_eva into main
2 changed files with 8 additions and 6 deletions

View file

@ -7,8 +7,9 @@ threads, timings = [], []
for file in os.listdir('timings'): for file in os.listdir('timings'):
with open(f'timings/{file}', 'r') as f: with open(f'timings/{file}', 'r') as f:
n, t = f.read().strip().split(',') n, t = f.read().strip().split(',')
threads.append(int(n)) if n != 'None':
timings.append(float(t)) threads.append(int(n))
timings.append(float(t))
threads = np.array(threads) threads = np.array(threads)
timings = np.array(timings) timings = np.array(timings)
@ -16,8 +17,9 @@ print('This is the data I loaded: threads =', threads, ', timings =',timings)
fig, axs = plt.subplots() fig, axs = plt.subplots()
# CREATE YOUR PLOT HERE axs.scatter(x=threads, y=timings, color = 'hotpink', marker = '*')
Review

It's a bit strange that spaces are used around the second two assignments, but not the first two.
In Python we generally don't use the spaces in this context.

It's a bit strange that spaces are used around the second two assignments, but not the first two. In Python we generally don't use the spaces in this context.
# Remember to label your axis axs.set_xlabel('Number of threads')
# Feel free to make it pretty axs.set_ylabel('Timing [s]')
axs.grid()
plt.savefig('threads_v_timings.png', dpi=300) plt.savefig('threads_v_timings', dpi=300)

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB