I have a problem in plotting some data from a list; values are not correct and I have to modify them.
this is the plot with the correlated functions:
import timeit
import numpy as np
import matplotlib.pyplot as plt
def factorise(n):
factors = []
for i in range(1,n+1):
if n%i == 0:
factors.append(i)
return factors
print('The following show the time needed to factorise each number in the interval:')
def list_of_times(number):
times = []
for i in range(1,number+1):
factorise(i)
t = timeit.repeat('factorise(5)', 'from __main__ import factorise',repeat = 1, number = 1)
times.append(t)
print("{} = {} seconds".format(i,t))
return times
number = 5
list_of_times(number)
#%%
x_values = np.arange(1,6)
print(f'x_values: {x_values}')
y_values = list_of_times(number)
print(f'y_values: {y_values}')
plt.plot(x_values,y_values)
plt.title('The time exploration function')
plt.ylabel('$\ time(sec)$')
plt.xlabel('$x$')
plt.grid(True) #These help the visualisation
plt.savefig('y_values_upto'+str(6)+'.png',dpi=100)
plt.show()
.png?part=0.1&view=1)
.png?part=0.2&view=1)
.png?part=0.3&view=1)
as you can see there s so many problems in the graph (i would like integers for x and I don't know why the y axes has these numbers)