INF205/lab_2/13/plot_elongation.py

31 lines
698 B
Python
Raw Normal View History

2024-03-05 09:35:30 +00:00
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import numpy as np
import pandas as pd
f = open('elongation.csv', 'r')
x = []
y_average = []
y_extreme = []
for l in f.readlines():
l = l.split(',')
x.append(l[0])
y_average.append(float(l[1]))
y_extreme.append(float(l[2]))
plt.plot(x, y_average, label = 'average')
plt.plot(x, y_extreme, label = 'extreme')
for i in range(len(x)):
plt.text(i,y_average[i],f'{y_average[i]:.2f}', color="blue")
for i in range(len(x)):
plt.text(i,y_extreme[i],f'{y_extreme[i]:.2f}', color="orange")
plt.title('Speedup after optimization')
plt.xlabel('N')
plt.ylabel('elongation')
plt.grid()
plt.legend()
plt.show()